Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven: what is the difference between install and install:install?

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?

like image 319
Terry Avatar asked Feb 13 '23 04:02

Terry


1 Answers

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.

like image 172
John Stauffer Avatar answered Apr 26 '23 19:04

John Stauffer