熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> Java開源技術 >> 正文

ant的一些偏門技巧

2022-06-13   來源: Java開源技術 
為減小 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>


From:http://tw.wingwit.com/Article/program/Java/ky/201311/28329.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.