一为减小 buildxml 文件的大小使用XML实体
把属性的设置都放一个XML文件中
propsxml 文件
<property name=builddir value=build />
然后在 buildxml 文件中加入如下
<!DOCTYPE project [<!ENTITY properties SYSTEM file:propsxml>]>
二将多个目录的源文件编译到一个地方
<javac destdir=build/classes>
<src path=src/>
<src path=src/>
</javac>
三保存构建时的信息
<project default=init>
<target name=init></target>
<property environment=env />
<property name=envCOMPUTERNAME value=${envHOSTNAME} />
<propertyfile comment=Build Information file=/buildinfoproperties>
<entry key=buildhost value=${envCOMPUTERNAME} />
<entry key=buildusername value=${username} />
<entry key=buildosname value=${osname} />
</propertyfile>
</project>
四去除属性文件的注释
属性文件
# 这里是注释会给过滤掉
builddir = build
build文件
<copy file=propsproperties todir=sample>
<filterchain>
<striplinecomments>
<comment value=# />
</striplinecomments>
</filterchain>
</copy>
五两个花俏的功能
声音提示
<project name=Sound default=all>
<property file=buildproperties />
<target name=init>
<sound>
<success source=${sounddir}/successwav duration= />
<fail source=${sounddir}/failwav loops= />
</sound>
</target>
<target name=fail depends=init>
<fail />
</target>
<target name=success depends=init />
<target name=all depends=success />
</project>
进度条提示
<project name=splash default=init>
<target name=init>
<splash imageurl=_//gif showduration= />
<sleep seconds= />
<sleep seconds= />
<sleep seconds= />
<sleep seconds= />
<sleep seconds= />
<sleep seconds= />
</target>
</project>