Created
July 30, 2013 09:23
-
-
Save bcremer/6111530 to your computer and use it in GitHub Desktop.
Apache ANT If/Else-Condition without ANT-Contrib
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<project name="Ant Condition Example"> | |
<target name="myConditionalTask" depends="myConditionalTask-check, myConditionalTask-fail" if="myConditionalTask-check-property"> | |
<echo message="EXECUTE myConditionalTask" /> | |
</target> | |
<target name="myConditionalTask-fail" unless="myConditionalTask-check-property"> | |
<echo message="SKIPPED myConditionalTask" /> | |
</target> | |
<target name="myConditionalTask-check"> | |
<condition property="myConditionalTask-check-property"> | |
<equals arg1="${my.boolean.property}" arg2="true" trim="true"/> | |
</condition> | |
</target> | |
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ant myConditionalTask | |
ant myConditionalTask -Dmy.boolean.property=false | |
myConditionalTask-check: | |
myConditionalTask-fail: | |
[echo] SKIPPED myConditionalTask | |
myConditionalTask: | |
BUILD SUCCESSFUL | |
Total time: 0 seconds | |
ant myConditionalTask -Dmy.boolean.property=true | |
myConditionalTask-check: | |
myConditionalTask-fail: | |
myConditionalTask: | |
[echo] EXECUTE myConditionalTask | |
BUILD SUCCESSFUL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment