Skip to content

Instantly share code, notes, and snippets.

@jeffjohnson9046
Created June 11, 2020 20:35
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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