Language Ant
| Date: | 05/18/05 |
| Author: | K. Seifert |
| URL: | n/a |
| Comments: | 2 |
| Info: | http://ant.apache.org/ |
| Score: |
<!--
Author: K. Seifert 2005
1. Ant is a Java build tool
(sorta like a cross between make and xml)
More Info: http://ant.apache.org/
2. This script requires the library ant-contrib.jar
More Info: http://ant-contrib.sourceforge.net/
Drop this jar in ${ANT_HOME}/lib/
-->
<project name="Bottles" default="init">
<taskdef
resource="net/sf/antcontrib/antcontrib.properties" />
<target name="init">
<var name="i" value="99" />
<antcall target="sing" />
</target>
<target name="sing">
<echo>${i} bottles of beer on the wall</echo>
<echo>${i} bottles of beer</echo>
<antcall target="drink" />
</target>
<target name="drink">
<math result="i" operand1="${i}" operation="-"
operand2="1" datatype="int" />
<echo>take one down, pass it around</echo>
<if>
<not>
<equals arg1="${i}" arg2="1" />
</not>
<then>
<echo>${i} bottles of beer</echo>
<antcall target="sing" />
</then>
<else>
<echo>one bottle of beer on the wall</echo>
</else>
</if>
</target>
</project>
Download Source | Write Comment
Download Source | Write Comment
Add Comment
Please provide a value for the fields Name,
Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.
Please don't post large portions of code here! Use the form to submit new examples or updates instead!
Comments
<project name="Bottles" default="init">
<taskdef resource="net/sf/antcontrib/antcontrib.properties" />
<target name="init">
<var name="i" value="99" />
<antcall target="sing" />
</target>
<target name="sing">
<switch value="${i}">
<case value="0">
<echo>no more bottles of beer on the wall</echo>
<echo>no more bottles of beer</echo>
</case>
<case value="1">
<echo>1 bottle of beer on the wall</echo>
<echo>1 bottle of beer</echo>
</case>
<default>
<echo>${i} bottles of beer on the wall</echo>
<echo>${i} bottles of beer</echo>
</default>
</switch>
<antcall target="drink" />
</target>
<target name="drink">
<math result="i" operand1="${i}" operation="-" operand2="1"
datatype="int" />
<switch value="${i}">
<case value="-1">
<echo>Go to the store and buy some more</echo>
<echo>99 bottles of beer.</echo>
</case>
<case value="0">
<echo>take one down, pass it around</echo>
<echo>no more bottles of beer on the wall</echo>
<antcall target="sing" />
</case>
<case value="1">
<echo>take one down, pass it around</echo>
<echo>1 bottle of beer on the wall</echo>
<antcall target="sing" />
</case>
<default>
<echo>take one down, pass it around</echo>
<echo>${i} bottles of beer on the wall</echo>
<antcall target="sing" />
</default>
</switch>
</target>
</project>