antoine
antoine

Reputation: 823

Maven plugin additional executions

I need to execute the same maven plugin more than once in the same phase.

What I want:

  1. Execute maven-assembly-plugin
  2. Execute myplugin (depends on step 1)
  3. Execute maven-assembly-plugin again (depends on step 2)
  4. Execute myplugin again (depends on step 3)

Execution order when I define the plugins sequentially (same order as above):

  1. Execute maven-assembly-plugin
  2. Execute maven-assembly-plugin again
  3. Execute myplugin
  4. Execute myplugin again

My solution is to combine all executions in my own plugin to control the exact order, but I don't think it's the best way to do it. Thanks !

Upvotes: 2

Views: 826

Answers (1)

Antti Kolehmainen
Antti Kolehmainen

Reputation: 1081

Do you absolutely have to run the plugins during the same exact phase? Can't you use some other related phase? Maven has a lot of phases nowadays :) e.g. "prepare-package" vs. "package". I would probably try to define multiple executions for the plugin like this (bwt this is not a real-world scenario):

         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.2.1</version>
            <executions>
                <execution>
                    <id>assembly1</id>
                    <goals>
                        <goal>assembly</goal>
                    </goals>
                    <phase>prepare-package</phase>
                    <configuration>
                        <descriptorRefs>
                            <descriptorRef>jar-with-dependencies</descriptorRef>
                        </descriptorRefs>
                    </configuration>
                </execution>
                <execution>
                    <id>assembly2</id>
                    <goals>
                        <goal>assembly</goal>
                    </goals>
                    <phase>package</phase>
                    <configuration>
                        <descriptorRefs>
                            <descriptorRef>jar-with-dependencies</descriptorRef>
                        </descriptorRefs>
                    </configuration>
                </execution>
            </executions>
        </plugin>

Not sure if it will work for your desired order though. Might be worth a try.

Upvotes: 2

Related Questions