假设插件作者未能在其文档中提及maven插件的默认阶段,我想弄明白。
运行mvn -X verify
以
[DEBUG] Lifecycle default -> [validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy]
[DEBUG] Lifecycle clean -> [pre-clean, clean, post-clean]
[DEBUG] Lifecycle site -> [pre-site, site, post-site, site-deploy]
[DEBUG] Lifecycle default -> [validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy]
[DEBUG] Lifecycle clean -> [pre-clean, clean, post-clean]
[DEBUG] Lifecycle site -> [pre-site, site, post-site, site-deploy]
[DEBUG] Lifecycle default -> [validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy]
[DEBUG] Lifecycle clean -> [pre-clean, clean, post-clean]
[DEBUG] Lifecycle site -> [pre-site, site, post-site, site-deploy]
[DEBUG] Lifecycle default -> [validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy]
[DEBUG] Lifecycle clean -> [pre-clean, clean, post-clean]
[DEBUG] Lifecycle site -> [pre-site, site, post-site, site-deploy]
[DEBUG] Lifecycle default -> [validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy]
[DEBUG] Lifecycle clean -> [pre-clean, clean, post-clean]
[DEBUG] Lifecycle site -> [pre-site, site, post-site, site-deploy]
告诉我,maven可以打印相同的字符串五次到stdout
,然后是
[DEBUG] -----------------------------------------------------------------------
[DEBUG] Goal: org.apache.maven.plugins:maven-checkstyle-plugin:2.6:check (checkstyle)
[DEBUG] Style: Regular
[DEBUG] Configuration: [...]
为每个插件后跟“Dependency collection stats”,然后是插件的调试输出。
我是否必须假设 - 即使在具有最大详细程度(afaik)的10000行调试输出中,工作phase
也不会发生,并且搜索引擎仅显示1000个重复解释,相位是什么maven生命周期 - 这是一个保密的秘密。
我在Ubuntu 15.04上使用maven 3.3.1和Linux 4.0.1。
答案 0 :(得分:3)
好问题: - )
我相信插件作者probablby忘记了文档?所以关于插件信息中的目标和阶段的信息(希望如此)。
对于maven-compiler-plugin,如果你下载jar并解压缩它,那么maven-compiler-plugin-3.3\META-INF\maven\plugin.xml
中有一个plugin.xml
该插件包含mojo(目标)及其配置阶段:
<mojos>
<mojo>
<goal>compile</goal>
<description>Compiles application sources</description>
<requiresDependencyResolution>compile</requiresDependencyResolution>
<requiresDirectInvocation>false</requiresDirectInvocation>
<requiresProject>true</requiresProject>
<requiresReports>false</requiresReports>
<aggregator>false</aggregator>
<requiresOnline>false</requiresOnline>
<inheritedByDefault>true</inheritedByDefault>
<phase>compile</phase>
<implementation>org.apache.maven.plugin.compiler.CompilerMojo</implementation>
<language>java</language>
这里编译目标在<phase>
编译中运行。我希望你好奇的插件也包含这个。
答案 1 :(得分:2)
例如,上述文档针对目标compile
显示以下内容:
Requires a Maven project to be executed.
Requires dependency resolution of artifacts in scope: compile.
The goal is thread-safe and supports parallel builds.
Since version: 2.0.
Binds by default to the lifecycle phase: compile.
这意味着(最后一行)默认情况下,maven-compile-plugin绑定到生命周期阶段:compile
如果没有被覆盖。此外,reference documentation显示哪些插件绑定到哪个阶段。
除了上述内容,如果插件作者决定不将插件绑定到默认生命周期,它将不会成为文档的一部分。如果插件作者决定将插件绑定到生命周期阶段,则会自动记录cause it's generated from source code.
代码如下所示:
@org.apache.maven.plugins.annotations.Mojo(
name = "compile",
defaultPhase = LifecyclePhase.COMPILE,
threadSafe = true,
requiresDependencyResolution = ResolutionScope.COMPILE )
public class CompilerMojo
extends AbstractCompilerMojo
{
从上面的代码中生成文档。