Maven Basics
Plan
Learn the basics of Maven
Prerequisites
- Java
- Maven - https://maven.apache.org/install.html
Notes
- Dependency management and build tool
- Maven Central is one of the central repositories - https://mvnrepository.com/
- Maven gets all dependecies from Maven Central
- Helps to maintain common structure across organizations
- Provides templates
- Flexibility in integrating with CI tools
- Supports various plugins. Ex: TestNG, JUnit
- Group Id should be unique across all the projects in Maven repository
Commands
Check the version of Maven installed
mvn --version
Create a sample Maven quick start project
mvn archetype:generate -DgroupId=com.tryonyourown.example -DartifactId=SampleMavenProject -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
- Maven compiler plugin
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>10</source>
<target>10</target>
</configuration>
</plugin>
</plugins>
</build>