---
title: "Apache Ant"
author: "asran"
date: "2010-12-22T13:22:47Z"
tags: []
categories: ["编程语言"]
slug: "apache-ant"
draft: false
lastmod: "2010-12-22T13:22:47Z"
id: 849251
url: "https://asran.iteye.com/blog/849251"
---

1\. Add additional command line arguments for &lt;javac&gt; task:

&lt;javac srcdir="${dist}/trsWeb" destdir="${dist}/build/trsWeb"

    fork="true" classpath="${compile\_classpath}" source="1.5" target="1.5"

    nowarn="true"&gt;

    &lt;compilerarg value="-J-Duser.language=en"/&gt;

&lt;/javac&gt;

 

2\. if...else...

&lt;if&gt;

    &lt;equals arg1="${hello}" arg2="true"/&gt;

    &lt;then&gt;

        &lt;echo &gt;${hello} value is true&lt;/echo&gt;

    &lt;/then&gt;

    &lt;elseif&gt;

        &lt;equals arg1="${hello}" arg2="false"/&gt;

        &lt;then&gt;

            &lt;echo &gt;${hello} value is false&lt;/echo&gt;

        &lt;/then&gt;

    &lt;/elseif&gt;

    &lt;else&gt;

         &lt;echo &gt;${hello} value is unknowe&lt;/echo&gt;

    &lt;/else&gt;

&lt;/if&gt;

 

3\. placeholder variables in build.xml

build.properties

\--------------------

key=value

 

build.xml

\--------------------

&lt;project name="TestAntPlaceHolder" default="echo" basedir="."&gt;

&lt;property file="build.properties" /&gt; &lt;---- mandatory, no default property file biult-in.

&lt;target name="echo"&gt;

&lt;echo message="I'm ${key}..."/&gt;

&lt;/target&gt;

&lt;/project&gt;