Reputation: 21
I need to skip an execution when any of 2 conditions occurs.
Something like this:
mvn clean test -DconditionA=false -DconditionB=false
This is my example pom:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>list-dir</id>
<phase>validate</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>ls</executable>
<workingDirectory>.</workingDirectory>
<arguments>
<argument>-ls</argument>
</arguments>
<skip>${conditionA}</skip>
<skip>${conditionB}</skip>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
What I want is to be able to skip this execution wether conditionA or conditionB are true. Just second skip works as it overrides 1st one.
Is there any way to achieve this?
Upvotes: 2
Views: 1945
Reputation: 28086
You can use a profile to overwrite conditionA
when conditionB
is set to true:
<profiles>
<profile>
<activation>
<property>
<name>conditionB</name>
<value>true</value>
</property>
</activation>
<property>
<conditionA>true</conditionA>
</property>
</profile>
</profiles>
This will work for:
mvn clean test -DconditionA=true
or:
mvn clean test -DconditionB=true
It might not work for:
mvn clean test -DconditionA=false -DconditionB=true
I haven't tried it. If it doesn't, and you actually need that, you'll need to add another property and profiles for both A and B that set it.
Upvotes: 1