在 Maven 中,我如何找出目标的默认阶段(如果该特定目标存在任何默认阶段)?
Example
我正在使用一个名为的 Maven 插件Jetty Maven 插件 http://wiki.eclipse.org/Jetty/Feature/Jetty_Maven_Plugin。它包含一个目标jetty:run
。运行命令mvn jetty:run
(注意这个命令只包含一个目标,而不是一个阶段)首先构建一个pom.xml
-指定的Web应用程序最高可达默认值test-compile phase http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference,然后将其部署到 Jetty 服务器内。
正如中指出的Mojo API 规范 http://maven.apache.org/developers/mojo-api-specification.html,一个目标可以在其源代码中分配一个默认阶段(通过@phase
or via @execute phase
). 的情况下jetty:run,默认相位为@execute phase="test-compile" http://grepcode.com/file_/repo1.maven.org/maven2/org.mortbay.jetty/jetty-maven-plugin/8.1.4.v20120524/org/mortbay/jetty/plugin/JettyRunMojo.java/?v=source.
但查找源代码文件可能会变得相当复杂。有没有更简单的方法来找出默认阶段?
最简单的解决方案是使用maven 帮助插件 http://maven.apache.org/plugins/maven-help-plugin/describe-mojo.html像下面这样:
mvn help:describe -DartifactId=maven-compiler-plugin -DgroupId=org.apache.maven.plugins -Dgoal=compile -Ddetail
这将打印出许多信息,但在第一行:
[INFO] Mojo: 'compiler:compile'
compiler:compile
Description: Compiles application sources
Implementation: org.apache.maven.plugin.CompilerMojo
Language: java
Bound to phase: compile
Available parameters:
....
如果你尝试为 jetty:run 像这样:
mvn help:describe -DartifactId=jetty-maven-plugin -DgroupId=org.mortbay.jetty -Dgoal=run -Ddetail
您将获得大量输出,但不会看到默认阶段,因为它是从命令行调用的:
[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:
....
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)