Maven TutorialIntroduction to Maven Installation and environment configuration Maven settings Standard directory structure in Maven project command line IntelliJ IDEA Super POM and Parent POM Understanding POM.xml file Declaring maven dependencies Dependency management using repositories in Maven Adding jar file as a dependency in Maven Maven archetypes Maven build life cycle, phases and goals Generating project API documentation Generating Site documentation for a project Installing artifacts in local repository Deploying the artifact on remote repository Maven plug-ins surefire plugin compiler plugin Profiles in MavenExecuting Maven phases and goals through command prompt Maven command line optionsexec-maven-plugin usage Skipping tests in Maven Test execution report in Maven
Build lifecyle in MavenA build lifecycle has fixed number of phases and in each phase, one or more goals(tasks) are executed. There are 3 standard life cycles in maven.
- clean lifecycle – preclean, clean, postclean
- site lifecycle – presite, site, postsite
- build lifecycle – [see below]
- validate – Validates that project is ready to be built.
- initialize – Initializes build process
- generate-sources – Generate any source code
- process-sources – Process the source code
- generate-resources – Generate resources
- process-resources – Process the resources
- compile – Compile the source code
- process-classes – process compiled classes.
- generate-test-sources – Generate test source code
- process-test-sources – Process the test source code
- test-compile – Compile the test source code
- process-test-classes Process the test source code files
- test – Run tests (JUnit/testNG tests in project)
- prepare-package – Prepare a package.
- package – Package the code in formats like JAR, WAR, or EAR depending upon project type and packaging specified in POM file
- pre-integration-test – tasks before integration tests are executed
- integration-test – run integration tests
- post-integration-test – tasks after integration tests are executed
- verify – verify the package
- install – put the package in local repository
- deploy – store the package on remote repository for distribution purpose
Each phase can execute one or more goals. For example, when we say we are executing test phase, we are actually executing test goal. But it does not mean that we can only execute only test goal in test Phase. We can also configure maven to execute other goals in any phase.
Complex problems, Simple Solutions