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

Order of executing plugins in maven 2.0.9

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Duplicate
    • 2.0.9
    • None
    • Plugins and Lifecycle
    • None
    • Maven 2.0.9

    Description

      Suppose you include a plugin like this:

      <plugin>
      <groupId>my.bug.test</groupId>
      <artifactId>plugin</artifactId>
      <version>1.0</version>
      <executions>
      <execution>
      <id>first</id>
      <phase>compile</phase>
      <goals>
      <goal>first</goal>
      </goals>
      </execution>
      </executions>
      </plugin>
      <plugin>
      <groupId>my.bug.test</groupId>
      <artifactId>plugin</artifactId>
      <version>1.0</version>
      <executions>
      <execution>
      <id>second</id>
      <phase>compile</phase>
      <goals>
      <goal>second</goal>
      </goals>
      </execution>
      </executions>
      </plugin>

      Then SECOND will execute before FIRST. The reason is in ModelUtils.java:MergePluginDefinitions the new definition is passed as parent and the old as child - and the parent comes first in the merged executions.

      However, this works correctly:

      <plugin>
      <groupId>my.bug.test</groupId>
      <artifactId>plugin</artifactId>
      <version>1.0</version>
      <executions>
      <execution>
      <id>both</id>
      <phase>test</phase>
      <goals>
      <goal>first</goal>
      <goal>second</goal>
      </goals>
      </execution>
      </executions>
      </plugin>

      I have included a tiny test case that demonstrates this. Here's my output:

      [INFO] [compiler:compile]
      [INFO] No sources to compile
      [INFO] [:second

      {execution: second}

      ]
      SECOND
      [INFO] [:first

      {execution: first}

      ]
      FIRST
      [INFO] [resources:testResources]
      [INFO] Using default encoding to copy filtered resources.
      [INFO] [compiler:testCompile]
      [INFO] No sources to compile
      [INFO] [surefire:test]
      [INFO] No tests to run.
      [INFO] [:first

      {execution: both}

      ]
      FIRST
      [INFO] [:second

      {execution: both}

      ]
      SECOND

      Attachments

        1. 209test.zip
          2 kB
          David Bernhard

        Issue Links

          Activity

            People

              brett Brett Porter
              elca-dbd David Bernhard
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: