Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-4727

Allow ordering plugin execution via <id/>

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 2.2.1
    • None
    • None
    • None

    Description

      I would like to be able to deterministically order the execution of plugins bound to the same lifecycle phase. I have a project where I need to execute the antrun plugin, then the install4j-maven-plugin, again the antrun plugin and finally the rpm-maven-plugin.

      I would like to be able to do this:

      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.4</version>
        <executions>
          <execution>
            <id>step-1-extract-tomcat6x</id>
            <phase>package</phase>
            <goals><goal>run</goal></goals>
            <configuration>
                ...
            </configuration>
          </execution>
          <execution>
            <id>step-3-extract-install4j-tar-gz-file</id>
            <phase>package</phase>
            <goals><goal>run</goal></goals>
            <configuration>
                 ...
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>com.google.code.maven-install4j</groupId>
        <artifactId>maven-install4j-plugin</artifactId>
        <version>0.2-mvn-2.2.1</version>
        <executions>
          <execution>
            <id>step-2-build-installers</id>
            <phase>package</phase>
            <goals><goal>compile</goal></goals>
          </execution>
        </executions>
        <configuration>
             ...
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>rpm-maven-plugin</artifactId>
        <version>2.1-alpha-1</version>
        <executions>
          <execution>
            <id>step-4-create-rpm</id>
            <phase>package</phase>
            <goals><goal>attached-rpm</goal></goals>
          </execution>
        </executions>
        <configuration>
             ...
        </configuration>
      </plugin>
      

      When defined like this, the execution order should be:

      1. step-1-extract-tomcat6x
      2. step-2-build-installers
      3. step-3-extract-install4j-tar-gz-file
      4. step-4-create-rpm

      With the current maven (2.2.1), you can do this if you order your plugins in the pom.xml correctly and you don't need the same plugin twice. Depending on the <id/> (with natural sorting on String) would allow to declare the same plugin twice.

      An alternative might be to add an additional element to <execution/>, like <order/> or something that only accepts a number.

      Attachments

        1. plugin_execution_order.patch
          2 kB
          Wim Deblauwe

        Issue Links

          Activity

            People

              bentmann Benjamin Bentmann
              wim.deblauwe@gmail.com Wim Deblauwe
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: