Domanda

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?

È stato utile?

Soluzione

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.

Altri suggerimenti

The syntax for a goal is: < plugin-name >:< goal >

For example:

install:install means that you are executing the goal install on the plugin "maven-install-plugin".

The plugin install has 3 goals: install, install-file and help

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top