Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I find out the default phase a Maven goal binds to?

In Maven, how can I find out the default phase of a goal (if any default phase exists at all for this particular goal)?

Example

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?

like image 204
Abdull Avatar asked Sep 06 '12 23:09

Abdull


1 Answers

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:
      ....
like image 163
khmarbaise Avatar answered Oct 14 '22 00:10

khmarbaise