What does the <id> value indicate to run a Maven plugin?

A Maven item <plugin>

has an item <executions>

that contains multiple items <execution>

. Each element <execution>

can have an element <id>

containing a string. What are the links to those items <id>...</id>

? What does it mean to skip this item? What is the semantics of the element <id>

?

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 are these values <id>default-jar-execution</id>

and <id>extra-jar-execution</id>

? What is the behavioral difference in changing any of these lines? What does it mean to remove these elements?

+3


source to share


1 answer


The element id

has two functions:

  • Documentation
  • Let Maven know when you want to create a new execution and when you want to modify an existing one.

The first case is simple: it just lets you give a meaningful name.



The second case means that Maven has standard executions, which you can see, for example, at startup mvn help:effective-pom

. If you want to replace / extend an existing performance, you need to use the same one id

. Then Maven will merge them.

See http://maven.apache.org/guides/mini/guide-configuring-plugins.html#Using_the_executions_Tag

Executions of the same identifier from different POMs are merged.

+4


source







All Articles