Reputation: 8788
Assume a plugin author has failed to mention the default phase of a maven plugin in its documetnation and I want to figure it out.
Running mvn -X verify
give output in the form of
[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]
which tells me that maven can print the same string five times to stdout
followed by a listing in the form of
[DEBUG] -----------------------------------------------------------------------
[DEBUG] Goal: org.apache.maven.plugins:maven-checkstyle-plugin:2.6:check (checkstyle)
[DEBUG] Style: Regular
[DEBUG] Configuration: [...]
for every plugin followed by "Dependency collection stats" followed by debug output of plugins.
Do I have to assume - regarding the fact that even in 10000 lines of debug output with maximal verbosity (afaik) the work phase
does not occur and search engines only reveal 1000s of duplicate explanations what a phase is in the maven lifecycle - that this is a secret to be kept.
I'm using maven 3.3.1 on Ubuntu 15.04 with Linux 4.0.1.
Upvotes: 2
Views: 1068
Reputation: 97527
The default phase for a goal to be bound at is documented on the appropriate plugin page.
For example the above doc shows for the goal compile
the following:
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.
This means (last line) by default the maven-compile-plugin is bound to the life cycle phase: compile
if not overwritten. Furthermore the reference documentation shows which plugins are bound to which phase.
Apart from the above if a plugin author has decided not to bind a plugin to a default life cycle it will not being part of the documentation. If a plugin author decided to bind a plugin to a life cycle phase this is automatically documented cause it's generated from source code.
The code looks like this:
@org.apache.maven.plugins.annotations.Mojo(
name = "compile",
defaultPhase = LifecyclePhase.COMPILE,
threadSafe = true,
requiresDependencyResolution = ResolutionScope.COMPILE )
public class CompilerMojo
extends AbstractCompilerMojo
{
And from the above code the documentation will generated.
Upvotes: 3
Reputation: 8160
Good question :-)
I believe that the plugin author probablby just forgot the documentation? So the information on the goals and phases in the plugin information (hopefully).
For the maven-compiler-plugin, if you download the jar and extract it there is a plugin.xml in maven-compiler-plugin-3.3\META-INF\maven\plugin.xml
That plugin contains that mojo's (goals) and the phase they are configured for:
<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>
Here the compile goal runs in <phase>
compile. I would hope the plugin your curious about contains this as well.
Upvotes: 4