我如何找出Maven目标绑定到的默认阶段? [英] How can I find out the default phase a Maven goal binds to?
问题描述
在Maven中,如何找出目标的默认阶段(如果针对此特定目标根本没有任何默认阶段)?
In Maven, how can I find out the default phase of a goal (if any default phase exists at all for this particular goal)?
我正在使用一个名为 Jetty Maven插件的Maven插件.它包含一个目标jetty:run
.运行命令mvn jetty:run
(注意,此命令仅包含目标,而不是阶段),首先将构建pom.xml
指定的Web应用程序,直到默认的
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.
Mojo API规范中指出,目标可以在其源代码中(通过@phase
或通过@execute phase
)为其分配了默认阶段. .
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:
....
这篇关于我如何找出Maven目标绑定到的默认阶段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!