Given pom.xml
<plugin>
<groupId>com.myplugin</groupId>
<artifactId>my-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<id>generate-file</id>
<phase>package</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<templateFile>
${project.build.directory}/template.json
</templateFile>
<outputFile>
${project.build.directory}/${env}-${server}-file.json
</outputFile>
</configuration>
</execution>
<execution>
<id>send-file</id>
<phase>package</phase>
<goals>
<goal>send</goal>
</goals>
<configuration>
<file>
${project.build.directory}/${env}-${server}-file.json
</file>
</configuration>
</execution>
</executions>
</plugin>
<profiles>
<profile>
<id>dev-a</id>
<properties>
<env>test</env>
<server>serverA</server>
</properties>
</profile>
<profile>
<id>prod-a</id>
<properties>
<env>prod</env>
<server>serverA</server>
</properties>
</profile>
<profile>
<id>dev-b</id>
<properties>
<env>test</env>
<server>serverB</server>
</properties>
</profile>
<profile>
<id>prod-b</id>
<properties>
<env>prod</env>
<server>serverB</server>
</properties>
</profile>
</profiles>
How can I execute send-file
task only when env
property is equal to prod
? I know I can move the plugin
tag to dev-a
and prod-a
profiles in that example but I would need to duplicate that part for each profile which doesn't seem to be good solution. In my case I have many more profiles defined and the plugin execution definition is much longer, it would clutter my pom file a lot and make any changes very error-prone.
Is there any condition tag that I can pass to execution that would let me decide if it is invoked or not? Or maybe is there a possibility to exclude executions by id in profile tag?
Thanks for help!