2. What is Maven?
Maven v/s ANT
Create a simple project in Maven
mvn archetype:generate -DgroupId=com.lumesse.talentcloud
-DartifactId=sample
-DarchetypeArtifactId=maven-archetype-quickstart
-DinteractiveMode=false
5. Maven Build Lifecycle and Phases:
Built-in Build Lifecycles:
• Default, Clean and Site
• The default lifecycle handles your project deployment, the clean lifecycle handles project cleaning,
while the site lifecycle handles the creation of your project's site documentation.
Standard Lifecycles:
• validate: validate the project is correct and all necessary information is available
• compile: compile the source code of the project
• test: test the compiled source code using a suitable unit testing framework. These tests should not
require the code be packaged or deployed
• package: take the compiled code and package it in its distributable format, such as a JAR.
• integration-test: process and deploy the package if necessary into an environment where
integration tests can be run
• verify: run any checks to verify the package is valid and meets quality criteria
• install: install the package into the local repository, for use as a dependency in other projects locally
• deploy: done in an integration or release environment, copies the final package to the remote
repository for sharing with other developers and projects.
6. 2 Ways to assign tasks to build phases
• Packaging
• Plug-ins
Jar Packaging:
7. Configuring Plug-ins
• Build plugins will be executed during the build
and then, they should be configured in the
<build/> element.
• Reporting plugins will be executed during the
site generation and they should be configured
in the <reporting/> element.
19. Good to Know Facts
1) Surefire plugin:
Accepted class names are
**/*Test.java
**/Test*.java
**/*TestCase.java
And the default excludes are:
**/Abstract*Test.java
**/Abstract*TestCase.java
2) Putting a jar in local repository
mvn install:install-file
-Dfile=<path-to-file>
-DgroupId=<group-id>
-DartifactId=<artifact-id>
-Dversion=<version>
-Dpackaging=<packaging> -DgeneratePom=true
20. Good to Know Facts
3) Skip tests in Maven:
-Dmaven.test.skip=true skips test compilation and execution
-DskipTests=true skips test execution only
4) Produce execution debug output or error messages in Maven
Use -X parameter or -e parameter
22. Creating your own Archetypes
• An archetype descriptor (archetype.xml in directory:
src/main/resources/META-INF/maven
• The prototype files that are copied by the archetype plugin (directory:
src/main/resources/archetype-resources/)
• The prototype pom (pom.xml in: src/main/resources/archetype-resources)
• A pom for the archetype (pom.xml in the archetype's root directory).