Filip
Filip

Reputation: 1066

Maven : how to order multiple execution of a goal in the same phase in a specfic order

I want my "pre-integration-test" phase to be the following execution of goals, in this specfic order.

PHASE : pre-integration-test

Is there any way to do this using Maven 3?

The problem that I am facing, is that "maven-antrun-plugin:run" 1 & 2 will always be run one after the other, because they are defined in the same plugin element :

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.8</version>
                <executions>
                    <execution>
                        <id>display-port</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <echo>Displaying value of 'tomcat.http.port' property</echo>
                                <echo>[tomcat.http.port] ${tomcat.http.port}</echo>
                            </target>
                        </configuration>
                    </execution>
                    <execution>
                        <id>wait-for-startup</id>
                        <phase>pre-integration-test</phase>
                        <configuration>
                            <target>
                                <sleep seconds="10" />
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

Right now, the only way I have found to do this is to duplicate the "maven-antrun-plugin:" plugin element in the pom file. But this gets me a warning

'build.plugins.plugin.(groupId:artifactId)' must be unique but found duplicate declaration

For the scope of this question, I am not looking for a work-around, such as changing the plugin for the "display-port" or "wait-for startup", or changing the phase on of the goals.

I just want to understand if what I am trying to do is possible or not.

Upvotes: 1

Views: 1446

Answers (1)

mikeyreilly
mikeyreilly

Reputation: 6943

If multiple executions have the same phase, then the first one to be executed will be the built-in one (e.g. maven-compiler-plugin) whose id is default-something, then the other executions will take place in the order they appear in your pom file.

Upvotes: 1

Related Questions