I\'m looking at the plugin section of a pom I\'m inspecting and found this:
org.apache.maven.plugins
The problem can not be treated with respect to id
tag only but notice the different values of it through the examples. This has been tested with maven 3.0.5. Consider the following pom part:
org.apache.maven.plugins
maven-docck-plugin
1.0
some-other-other-id
pre-site
pre-site
check
some-id
check
some-other-id
pre-site
check
When run mvn clean site
from command line it outputs the following:
[INFO] --- maven-docck-plugin:1.0:check (default) @ MavenJavaApplication ---
[INFO] Skipping unsupported project: MavenJavaApplication
[INFO] No documentation errors were found.
[INFO]
[INFO] --- maven-docck-plugin:1.0:check (some-other-id) @ MavenJavaApplication ---
[INFO] Skipping unsupported project: MavenJavaApplication
[INFO] No documentation errors were found.
Notice that the execution outputs are always in form of:
:: ()
From Build lifecycle basics:
A plugin goal represents a specific task (finer than a build phase) which contributes to the building and managing of a project. It may be bound to zero or more build phases. A goal not bound to any build phase could be executed outside of the build lifecycle by direct invocation. (...) Moreover, if a goal is bound to one or more build phases, that goal will be called in all those phases.
From Guide to configuring plugins: Configuring build plugins:
But if the goal is not bound to any lifecycle phase then it simply won't be executed during the build lifecycle.
From what is quoted, it may be concluded that the execution with id some-other-other-id
can be ran from the command line, but that is not so, it can never be ran - it will be covered in the 5th example.
The definition of goal
and a phase
in the first execution is enough for it to get run so it gets assigned a default execution id of value default
and it gets executed.
Since the phase is not defined anywhere this execution does not get executed. It can be verified by the fact that the output does not contain the line with its execution id.
This execution defines all three: an id
, a phase
and a goal
so it gets executed.
If you run (read the syntax in the docck plugin documentation):
mvn docck:check -Doffline=true
it will output:
[INFO] --- maven-docck-plugin:1.0:check (default-cli) @ MavenJavaApplication ---
From Guide to configuring default mojo executions:
Starting in Maven 2.2.0, each mojo invoked directly from the command line will have an execution Id of default-cli assigned to it, which will allow the configuration of that execution from the POM by using this default execution Id
You can provide the properties for the goal executed from CLI in three different ways:
id
of value default-cli
Specifically, the above command is equivalent of running
mvn docck:check
with the pom containing:
org.apache.maven.plugins
maven-docck-plugin
1.0
true
or:
org.apache.maven.plugins
maven-docck-plugin
1.0
default-cli
pre-site
check
true
This last part comes in handy if you want to keep the global configuration for some common properties in different executions, but you want a complete other set of properties for running from CLI.
Since the maven-docck-plugin
has no default binding I'll cover it with the maven-compiler-plugin. Consider an empty pom with jar
packaging. If you run:
mvn clean install
it will trigger the compile
phase also and you will see in output:
[INFO] --- maven-compiler-plugin:2.3.1:compile (default-compile) @ MavenJavaApplication ---
To cover the value of the id
tag, from Guide to Configuring Default Mojo Executions:
Likewise, each mojo bound to the build lifecycle via the default lifecycle mapping for the specified POM packaging will have an execution Id of default-
assigned to it, to allow configuration of each default mojo execution independently.
If you run mvn help:effective-pom you will find the default execution definition for compiler plugin in output:
default-compile
compile
compile
It gets inherited from super POM for the jar
packaging type:
When no packaging is declared, Maven assumes the artifact is the default: jar. The valid types are Plexus role-hints (read more on Plexus for a explanation of roles and role-hints) of the component role org.apache.maven.lifecycle.mapping.LifecycleMapping. The current core packaging values are: pom, jar, maven-plugin, ejb, war, ear, rar, par. These define the default list of goals which execute to each corresponding build lifecycle stage for a particular package structure.
In other words, the above default execution definition is the consequence of a default lifecycle mapping (documentation, definition ) for the compiler-plugin
:
The Compiler Plugin has two goals. Both are already bound to their proper phases within the Maven Lifecycle and are therefore, automatically executed during their respective phases.
- compiler:compile is bound to the compile phase and is used to compile the main source files.
From Guide to configuring plugins.html: Using the executions tag:
Note that while execution id's have to be unique among all executions of a single plugin within a POM, they don't have to be unique across an inheritance hierarchy of POMs. Executions of the same id from different POMs are merged. The same applies to executions that are defined by profiles.