In a Maven <plugin>
element there is an <executions>
element which contains multiple <execution>
elements. Each <execution>
element can have an <id>
element containing a string. What references those <id>...</id>
elements? What does it mean to omit that element? What are the semantics of the <id>
element?
For example:
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>default-jar-execution</id>
<configuration>
<finalName>mainjar</finalName>
</configuration>
</execution>
<execution>
<id>extra-jar-execution</id>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<finalName>anotherjar</finalName>
</configuration>
</execution>
</exectutions>
</plugin>
[...]
</plugins>
</build>
</project>
What references those <id>default-jar-execution</id>
and <id>extra-jar-execution</id>
values? What is the behavioral difference of changing either of those strings? What does it mean to remove those elements?
The id
element has two functions:
The first case is simple: It just allows you to give the execution a meaningful name.
The second case means that Maven comes with default executions which you can see when you run mvn help:effective-pom
, for example. If you want to replace/extend an existing execution, you need to use the same id
. Maven will then merge the two.
See http://maven.apache.org/guides/mini/guide-configuring-plugins.html#Using_the_executions_Tag
Executions of the same id from different POMs are merged.
For sake of completeness, I would note, that since Maven 3.3.1 (March 2015), there is also an option to use the execution-id, when calling maven specific goal from the command line.
See https://maven.apache.org/docs/3.3.1/release-notes.html
See discussion about this option here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With