java maven project code example

Example 1: mvn build project

# one of the following
# compiles java classes
mvn compile  
# creates a jar in target folder
mavn package
# creates a jar in target folder and adds to your local .m2 repository
mvn install

Example 2: what is maven

What is MAVEN?
    - Maven is a built automation tool.
    - Maven is a tool that helps us create projects easyly.
--> What is built?
    - Creating, adding, compiling, testing and deploying a project.
    All of these combined are called a Built.
    - Since maven is "built" automation tool, it helps us automate 
    all of these steps.
--> Similar tools like Maven?
    - ant
    - gradle
    - kotlin
-->   Most important file in a Maven project?
    - pom.xml is the most important file in a Maven project.

Example 3: maven create project from archetype command line

mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4 -DinteractiveMode=false

Example 4: example of simple maven pom java

<properties>        <maven.compiler.release>11</maven.compiler.release>    </properties>     <build>        <pluginManagement>            <plugins>                <plugin>                    <groupId>org.apache.maven.plugins</groupId>                    <artifactId>maven-compiler-plugin</artifactId>                    <version>3.8.1</version>                </plugin>            </plugins>        </pluginManagement>    </build>

Tags:

C Example