HelloWorld 善戰(zhàn)者,求之于勢(shì),不責(zé)于人;故能擇人而任勢(shì)。

          知止而后有定,定而后能靜,靜而后能安,安而后能慮,慮而后能得。物有本末,事有終始。知所先后,則近道矣。

            BlogJava :: 首頁 ::  :: 聯(lián)系 ::  :: 管理 ::
            167 隨筆 :: 1 文章 :: 40 評(píng)論 :: 0 Trackbacks
          1.project標(biāo)簽
          <project basedir=”.” name=”example” default=”main”>
          ….
          <target name=”main”>
          ….
          </target>
          ….
          </project>
          project 標(biāo)記包含3個(gè)屬性:
          。basedir 指定項(xiàng)目所在的目錄位置
          。name 設(shè)定項(xiàng)目的名稱
          。default 設(shè)頂項(xiàng)目的build執(zhí)行時(shí)預(yù)設(shè)的target

          2.target標(biāo)簽
          target標(biāo)簽在project標(biāo)簽之內(nèi),一個(gè)project可以包含多個(gè)target
          ….
          <target name=”init”>
          </target>
          <target desponds=”init” description=”執(zhí)行程序” name=”main”>
          </target>
          ….
          target 標(biāo)簽包含6個(gè)屬性
          。description 對(duì)于這個(gè)target的描述
          。name target的名稱
          。depends 所依賴的其他target
               example:
          {
               <target name=”x”/>
               <target name=”y”/>
               <target depends=”x,y” name=”z”/>
               …..
               執(zhí)行順序?yàn)閤yz
          }
          。if 檢查某個(gè)屬性(x)設(shè)置了,只有這個(gè)屬性(x)的時(shí)候target才執(zhí)行
               example
               {
                   <property name=”someOne” value=”someValue”/>
                   <target name=”init”>
                   </target>
                   <target if=”someOne” deends=”init” description=”執(zhí)行程序” name=”main”>
                   </target>
                   …..
                   只有someOne這個(gè)屬性被設(shè)置了,init執(zhí)行了,main才執(zhí)行
               }
          。unless 檢查某個(gè)屬性(x)是否被設(shè)置了,和if相反,只有這個(gè)屬性沒有設(shè)置的時(shí)候才執(zhí)行這個(gè)任務(wù)。
          。id 標(biāo)記這個(gè)target的id.
          3.task標(biāo)簽
          task 可以用來執(zhí)行一個(gè)特定的工作,在Ant中已經(jīng)做了許多工作,而且Ant的結(jié)構(gòu)也支持所以用者自己開發(fā)task,只要在使用前申明這個(gè)task就可以了
               example:
          {
               <target name=”xdoclet”>
                   <taskdef classpathref=”path” classname=”xdoclet.modules.ejb.A” name=”ejbdoclet”>
                   <taskdef          classpathref=”path” className=”xdoclet.modules.B” name=”jbossnet”>
                   <ejbdoclet ejbspec=”2.0” destDir=”src”>
                       <fileset dir=”src”      includes=”**/*.java” />
                       <deploymentdescriptior destDir=”src/META-INF” />
                       <homeinterface/>
                       <remoteinterface/>
                       <jboss version=”4.0” destDir=”src/META-INF” />
                       <jbossnet webDeploymentName=”hello” prefix=”hello” destDir=”build/hello/META-INF” targetNameSpace=”http://….” />
                       <packageSubstitution packages=”ejb” substituteWith=”interfaces”/>
                   </ejbdoclet>
               </target>
          }

          4.基本的元素
               ⑴property用來標(biāo)記project中一些公用的設(shè)定值,
               example:
          {
               ……
               <property id=”ref” name=”source” value=”src”/>
               <property name=”scr” refid=”ref” />
               <property name=”jboss.test.jbossmx” location=”${build.lib}/jboss-jmx.jar”/>
               ……

               也可以從其他文件取得屬性
               <property enviroment=”env” />
               <property resource=”org/jboss/tools/task.properties”/>
               <property file=”./task.properties”/>
          }
               ⑵路徑classpath可以在target中設(shè)置java的classpath
                       example:
          {
                       <target name=”compile-classes”>
                           <mkdir dir=”${build.classes}”/>
                           <javac destdir=”${build.classes}” target=”${javac.target}”>
                               <classpath>
                                   <pathelement Location=”{build.classes}”/>
                                   <pathelement Location=”{bodule.source}/test”/>
                                   <path refid=”javac.classpath”/>
                               </classpath>
                           </javac>
                       </target>
                       。。。。。。。
                       也可以通過path設(shè)定通用的路徑,然后在其他的位置應(yīng)用
                           <path id=”path”>
                               <fileset dir=”${lib}”>
                                   <include name=”*.jar”/>
                               </fileset>
                               <pathelement location=”${build.classes}”/>
                           </path>
                           <target name=”compile-classes”>
                               <mkdir dir=”${build.classes}”/>
                               <javac destdir=”{build.classes}” target=”${javac.target}”>
                                   <classpath      refid=”path”/>
                               </javac>
                           </target>
                           …….
          }

          ⑶文件相關(guān)的標(biāo)簽
          fileset用來描述一些文件的集合:
          。dir 設(shè)定fileset的根目錄的位置
          。exclude 設(shè)定fileset不包含的文件
          。include 設(shè)定fileset包含的文件
               example {
                   …..
                   <fileset      dir=”${source.java}”>
                       <include name=”**/*.properties”/>
                       <exclude name=”**/javax.servlet.jar”/>
                       <exclude name=”**/xxx.jar”/>
                   </fileset>
                   …
          }

          。dirset用來描述目錄的集合:
          。dir      設(shè)定dirset的根目錄位置
          。exclude設(shè)定dirset不包含的文件
          。include 設(shè)定dirset包含的文件
               example {
                   …..
                   <dirset      dir=”${build.dir }”>
                       <include name=”**/classes”/>
                       <exclude name=”**/*Test**”/>
                   </dirset>
                   …
          }
          。mkdir用來描述目錄的集合:
          。dir      設(shè)定要建立的目錄
               example
               {
                   …
                   <mkdir dir=”${build}”/>
                   <mkdir dir=”${build}/classes”/>
                   <mkdir dir=”${doc}/>
                   …
          }
          。copy用來復(fù)制文件
          。todir 用來設(shè)定復(fù)制文件的目的地
          。fileset做為要復(fù)制的文件的集合,在copy下可以放置多個(gè)fileset和其他文件的標(biāo)簽
                   example
                   {
                       …
                       <copy todir=”${build}/war”>
                           <fileset dir=”${src}/classes”></fileset>
                       </copy>
                       …
          }

          。delete 用來刪除文件
          。fileset做要?jiǎng)h除文件的集合,可以放多個(gè)標(biāo)簽和其他的文件的標(biāo)簽
                   example
                   {
                       …
                       <delete>
                           <fileset dir=”${build}” include=”**/*.java”/>
                       </delete>
                       …
          }

          5.結(jié)構(gòu)標(biāo)簽
          ⑴ant用來呼叫其他的build文件, 讓多個(gè)子文件可以一起工作
          ,antfile 指定的外部build文件
          。target 指定的外部build文件中的一個(gè)target

          <ant antfile=”anotherbuild.xml”/>
          <ant antfile=”anotherbuild.xml” target=”compile”/>
          ….
          ⑵antcall 可以調(diào)用其他的target
          。target 指定的target名稱
          。param 調(diào)用時(shí)傳的參數(shù)

          <target      name=”init”>
          </target>
          <antcall target=”iniit”>
               <param name=”parame1” value=”value1”/>
          </anticall>

          ⑶sequential 在sequential中的任務(wù)將被依照順序執(zhí)行

          <sequential>
               <anticall target=”task1”></anticall>
               <anticall target=”task2”></anticall>
               <anticall target=”task3”></anticall>
          </sequential>

          ⑷parallel 在parallel中的任務(wù)將會(huì)被并行執(zhí)行

          < parallel >
               <anticall target=”task1”></anticall>
               <anticall target=”task2”></anticall>
               <anticall target=”task3”></anticall>
          </ parallel >


          </script>

          posted on 2007-08-13 18:49 helloworld2008 閱讀(2597) 評(píng)論(0)  編輯  收藏 所屬分類: java
          主站蜘蛛池模板: 卓尼县| 延安市| 澄迈县| 德州市| 富源县| 南和县| 安塞县| 大新县| 新干县| 乐亭县| 灵寿县| 思南县| 沅陵县| 涞水县| 吉首市| 兰西县| 贵德县| 万安县| 邯郸县| 宣城市| 林芝县| 塘沽区| 伊春市| 肇源县| 新邵县| 夏河县| 师宗县| 大姚县| 成安县| 台东县| 静乐县| 大城县| 集安市| 峨山| 社会| 乐东| 合山市| 东山县| 西峡县| 新昌县| 宁晋县|