How to declare a before and after execution of a maven plugin around another plugin execution?

Viewed 29983

I would like to create an execution order in my plugin which surrounds a maven plugin with a before and after execution of another maven plugin. All 3 executions are part of the deploy phase.

Here is an example of what I want to do:

  • phase:deploy
  • url:get: execution-before
  • dependency:unpack
  • url:get: execution-after

Note: url:get is my own custo mojo and just executes an http get using commons httpClient.

I would usually attach the after plugin execution in the next phase but unfortunately deploy is the last phase of the jar lifecycle.

Thank you in advance,

Kostas


Note: The following plugins segment from my pom file creates the following execution order which is not expected:

  • phase:deploy
  • url:get: execution-before
  • url:get: execution-after
  • dependency:unpack

Plugin segment:

        <plugin>
            <groupId>com.blabla.stpadmin</groupId>
            <artifactId>maven-url-plugin</artifactId>
            <version>1.0-SNAPSHOT</version>
            <executions>
                <execution>
                    <id>stop-stpadmin-service</id>
                    <phase>deploy</phase>
                    <goals>
                        <goal>get</goal>
                    </goals>
                    <configuration>
        ...
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <id>unpack</id>
                    <phase>deploy</phase>
                    <goals>
                        <goal>unpack</goal>
                    </goals>
                    <configuration>
        ...
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>com.blabla.stpadmin</groupId>
            <artifactId>maven-url-plugin</artifactId>
            <version>1.0-SNAPSHOT</version>
            <executions>
                <execution>
                    <id>start-stpadmin-service</id>
                    <phase>deploy</phase>
                    <goals>
                        <goal>get</goal>
                    </goals>
                    <configuration>
        ...
                    </configuration>
                </execution>
            </executions>
        </plugin>
1 Answers
Related