In Maven, how can I find out the default phase of a goal (if any default phase exists at all for this particular goal)?
I am using a Maven plugin called Jetty Maven Plugin. It contains a goal jetty:run
. Running the command mvn jetty:run
(notice this command only contains a goal, not a phase) first builds a pom.xml
-specified web application up to the default test-compile
phase, then deploys it inside a Jetty server.
As pointed out in the Mojo API Specification, a goal can have a default phase assigned to it in its source code (via @phase
or via @execute phase
). In case of jetty:run
, the default phase is @execute phase="test-compile"
.
But finding the source code file can get quite complicated. Is there an easier way for finding out the default phase?
The simplest solution is to use the maven-help-plugin like the following:
mvn help:describe -DartifactId=maven-compiler-plugin -DgroupId=org.apache.maven.plugins -Dgoal=compile -Ddetail
which will printout many information but in the first lines:
[INFO] Mojo: 'compiler:compile'
compiler:compile
Description: Compiles application sources
Implementation: org.apache.maven.plugin.CompilerMojo
Language: java
Bound to phase: compile
Available parameters:
....
If you try that for jetty:run like this:
mvn help:describe -DartifactId=jetty-maven-plugin -DgroupId=org.mortbay.jetty -Dgoal=run -Ddetail
You will get a large output but you won't see a default phase, cause it's intended to be called from command line:
[INFO] Mojo: 'jetty:run'
jetty:run
Description: This goal is used in-situ on a Maven project without first
....
redeploying.
.....
Implementation: org.mortbay.jetty.plugin.JettyRunMojo
Language: java
Before this mojo executes, it will call:
Phase: 'test-compile'
Available parameters:
....
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