- Maven has the ability to download dependencies automatically based on the dependencies block you put in respective maven project’s pom.xml file.Maven is a powerful project management tool that is based on POM (project object model). It is used for projects build, dependency and documentation.POM is an acronym for Project Object Model. It contains information about project and configuration of the project such as dependencies, build directory, source directory, test source directory, plugins, goal, etc. Maven reads pom.xml and then executes goal.
- Open Source Build Tool developed by the Apache Group
- Take cares of the Builds, Dependencies, Reports, Distribution, Releases & Mailing List
- Helps in getting the right JAR files for each project from (mvnrespository.com)
The Project Object Model File(also called as pom.xml) contains the meta-data of the project and is also responsible to manage dependencies and to configure plugins which helps us in automating many repetitive tasks.
- Plugins enable us to run the lifecycle phases in our Maven Project
- Each Plugin is associated with a GOAL, which is linked to the lifecycle phase
- Plugins can be defined inside section, under the tag
- Compiles out java files, similar to running javac
groupId = org.apache.maven.plugins
artifactId = maven-compiler-plugin
mvn compiler: compile
mvn compiler: testCompile
- Runs Unit Test inside our Project and also generates Test Reports
groupId = org.apache.maven.plugins
artifactId = maven-surefire-plugin
mvn clean test
- Packages source code into an artifact and installs it into the Local Repository
groupId = org.apache.maven.plugins
artifactId = maven-install-plugin
mvn clean install
- Deploys the created Artifact into the Remote Repository
mvn clean deploy
We have a parent project (parent POM) that contains different sub-projects (sub-modules), each of which is again a normal Maven Project.
The parent POM usually encapsulates the other child’s and that’s why it is packaged as a POM instead usual packaging format of JAR.
Profiles can be used in Maven to create customized build configurations. This means customizing the behavior of our builds based on specific conditions.
mvn -Pskip-test clean install