You have a plugin that you want to add to two phases: test, and deploy. The test-phase binding should always run, but the deploy-phase binding should be optional.
Simply put the deploy-phase binding into a profile.
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>some.plugin.group</groupId>
<artifactId>my-maven-plugin</artifactId>
<executions>
<execution>
<id>test-1</id>
<phase>test</phase>
<goals>
<goal>do-stuff</goal>
</goals>
<configuration>
<param>value</param>
</configuration>
</execution>
<execution>
<id>test-2</id>
<phase>test</phase>
<goals>
<goal>do-stuff</goal>
</goals>
<configuration>
<param>value2</param>
</configuration>
</execution>
<execution>
<id>test-n</id>
<phase>test</phase>
<goals>
<goal>do-stuff</goal>
</goals>
<configuration>
<param>valueN</param>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>deploy-optional</id>
<build>
<plugins>
<plugin>
<groupId>some.plugin.group</groupId>
<artifactId>my-maven-plugin</artifactId>
<executions>
<execution>
<id>deploy-1</id>
<phase>deploy</phase>
<goals>
<goal>do-stuff</goal>
</goals>
<configuration>
<param>value-deploy</param>
</configuration>
</execution>
<execution>
<id>deploy-2</id>
<phase>deploy</phase>
<goals>
<goal>do-stuff</goal>
</goals>
<configuration>
<param>value-deploy-2</param>
</configuration>
</execution>
<execution>
<id>deploy-n</id>
<phase>deploy</phase>
<goals>
<goal>do-stuff</goal>
</goals>
<configuration>
<param>value-deploy-N</param>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
|
Under normal circumstances, you don't want the optional deployment bindings to execute, so you simply use:
mvn deploy |
However, in some cases, you want to run the extra deploy-phase mojo bindings. To do this, run:
mvn \-P deploy-optional deploy |