I'm new to Maven and am trying to understand how it works.
I understand there is a life cycle that consists of phases. Phases call their mojos. If one phase is called, all the preceding phases are executed too. This happens when I call mvn install
for example, right? All phases up to including install are executed.
But then, what does mvn install:install
do?
What is this syntax with the colon for?
install
is a Maven phase. It first invokes all phases prior to it in the lifecycle (e.g., compile, test, and package to name a few) and than invokes whichever mojo "goals" are attached to it.
install::install
is a mojo "goal", which performs a specific task (copies the target artifacts from the current project into the local repo).
In practical terms, executing mvn install
in an empty project will compile the project and it's tests, execute all tests, package the project into an appropriate artifact (i.e., jar, war, zip, etc.) and copy that artifact into your local repository so that it is available to other maven projects.
In most typical cases, you will want to execute maven phases to get a complete build. Individual goals are sometimes useful to perform tasks from non-standard plugins. For example, in a war
project using jetty:run
to get an app server pointing at your current directory.
You can also bind goals to lifecycle phases in your projects pom.xml file to customize your build.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With