TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

Apache Maven

Maven Build Lifecycle

In this post, we will discuss the Maven Build Lifecycle. Various Maven build phases and settings files.

Maven Settings file:

● Global settings -> Located in ${M2_HOME}/conf/settings.xml
● User’s settings -> Located in ${HOME}/.m2/settings.xml
● Contains configuration for local installation of Maven, such as repositories and profiles

Maven Archetypes

Maven archetypes allow us to create Maven projects on the fly.

● A rapid way to build sample projects
● Many archetypes available in remote repositories
● To use an archetype, run mvn archetype:generate
● Interactive, allowing us to choose an archetype and specify groupId, artifactId, and version.
● Generates a sample project directory, with some specifics that you provide.
● Some archetypes need properties supplied command-line as “-D<propName>=<propValue>”.

Maven Build Lifecycle

● A goal is a task performed by a plugin, such as compiler:compile and install:install-file
● The goals are bound to life cycle phases, in which they are executed.
● Phases and goals can both be executed directly from the command-line.

Various phases of maven build life cycle are listed below

  • validate
  •  clean
  • compile
  • test
  • package
  • integration-test
  • verify
  • install
  • deploy
  • site

 

Maven LifeCycle Mapping Eclipse

 

POM.xml

Maven Build Life Cycle

Running a build phase

Running various build phases are either by running commands or from the IDE like Eclipse or IntelliJ.

validate – validate the project is correct and all necessary information of the project  is available
compile – compile the source code files of the project
test – test the compiled source code using a suitable unit testing framework.
package – take the compiled code and package it in its distribution format, such as war, ear, jar.
integration-test – process and deploy the package if necessary into an environment where integration tests environment
verify – run any checks to verify the package is valid and meets quality
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

clean life-cycle
clean– removes all files in previous runs.

Site
Site– generates all the project documentation

mvn install

We can use mvn install to package the project and deploy it to the local repository automatically.
When we run “install” phase, all above phases “validate“, “compile“, “test“, “package“, “integration-test“, “verify” phase, including the current “install” phase will be executed orderly.

We can run “clean” and “install” together so that the latest project to your local repository.

/>  mvn clean install

 

Maven Tutorials on this website can be found at:
https://www.testingdocs.com/apache-maven-tutorial/

For more details on the Apache Maven, visit the official website at:
https://maven.apache.org/

 

Related Posts

Maven Download Verification Win11

Apache Maven /

Download Maven on Windows 11

Invalid Target Java Error

Apache Maven /

Fix Fatal Error compiling: Invalid target release in Maven Project

Maven Project from archetype

Apache Maven /

Create Maven Project from Archetype in NetBeans

Create New Project

Apache Maven /

Create a Maven Project skip archetype

Maven Download Button

Apache Maven /

Install Maven on Ubuntu Linux

‹ What is Maven?› Create a Simple Web application with Maven

Recent Posts

  • Update draw.io on Windows
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows
  • Activate CLion IDE
  • CLion IDE for C/C++ Development

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com