i can pass 2 properties , b maven via
mvn test -da=true
or
mvn test -db=true
if either or b defined want target skipped. found possible when considered this:
<plugin> <artifactid>maven-antrun-plugin</artifactid> <version>1.7</version> <executions> <execution> <id>skiptthisconditionally</id> <phase>test</phase> <configuration> <target name="anytarget" unless="${a}"> <echo message="this should skipped if or b holds" /> </target> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin>
now b has considered too. can done?
matthias
i external build.xml
file allowing define multiple target combined antcall
, using 1 additional dummy target, check second condition.
pom.xml
<plugin> <artifactid>maven-antrun-plugin</artifactid> <version>1.7</version> <executions> <execution> <id>skiptthisconditionally</id> <phase>test</phase> <configuration> <target name="anytarget"> <ant antfile="build.xml"/> </target> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin>
and build.xml
<?xml version="1.0" encoding="utf-8"?> <project name="skipit" default="main"> <target name="main" unless="${a}"> <antcall target="secondtarget"></antcall> </target> <target name="secondtarget" unless="${b}"> <echo>a not true , b not true</echo> </target> </project>
alternative solution if have 2 conditions: using <skip>
configuration attribute 1 condition (i.e. maven stuff) , unless
(i.e. ant stuff) other condition:
<plugin> <artifactid>maven-antrun-plugin</artifactid> <version>1.7</version> <executions> <execution> <id>skiptthisconditionally</id> <phase>test</phase> <configuration> <skip>${a}</skip> <target name="anytarget" unless="${b}"> <echo>a not true , b not true</echo> </target> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin>
Comments
Post a Comment