Skip to content

Instantly share code, notes, and snippets.

@jeffjohnson9046
Created June 11, 2020 20:35
Show Gist options
  • Save jeffjohnson9046/b89b2d62135d5e954c6a700318191a12 to your computer and use it in GitHub Desktop.
Save jeffjohnson9046/b89b2d62135d5e954c6a700318191a12 to your computer and use it in GitHub Desktop.
A quick test of condition elements in ant
<project name="condition-test" default="all">
<target name="condition">
<condition property="isTomcat">
<matches pattern="^(tomcat)" string="${webContainer}" />
</condition>
<condition property="isWebLogic">
<matches pattern="^(web)" string="${webContainer}" />
</condition>
</target>
<target name="all" depends="condition">
<echo message="the value of webContainer is ${webContainer}"/>
<echo message="isTomcat = ${isTomcat}"/>
<echo message="isWebLogic = ${isWebLogic}"/>
</target>
</project>
# Test:
$ ant -f ant-condition-test.xml -DwebContainer=tomcat
Buildfile: /Users/jeff.johnson/dev/ant-condition-test.xml
condition:
all:
[echo] the value of webContainer is tomcat
[echo] isTomcat = true
[echo] isWebLogic = ${isWebLogic}
BUILD SUCCESSFUL
Total time: 0 seconds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment