Ant的一些常用任务

上一篇 / 下一篇  2015-08-18 20:42:47 / 个人分类:持续集成

<?xml version="1.0" encoding="UTF-8"?>

<projectname="javacTest"default="info">

'v.O*},up!K0

   <!--打印信息echo标签,property相当于变量-->

&S(iTM9HXL0

   <propertyname="message"value="开始ant"></property>51Testing软件测试网H.~ GY.{5Vp"p

   <propertyfile="build.properties"/>51Testing软件测试网N\X"KY:C

     <targetname="preper"unless="name">

n)c7vhm o#}{0

       <echomessage="name不存在"file="log/log.txt"append="true"/>

0HB}#xN0

       </target>51Testing软件测试网A&{?ME9R

   <!--如果proname属性存在,则打印-->

+P`i(s3Qo0

   <targetname="info"depends="preper"if="proname">   

1W'Z5O;F H(M p5d#X0

       <echomessage="${proname}"file="log/log.txt"append="true"/>51Testing软件测试网8V,[)ltd

    </target> 51Testing软件测试网w h#q_0JiBae$e

</project>51Testing软件测试网k?-@9s}$Q

其他一些ant的内置属性:51Testing软件测试网R5p!~'~kL9I

        <echo>${ant.java.version}</echo>51Testing软件测试网7X[| gBQt

        <echo>${ant.project.name}</echo>51Testing软件测试网 fL A"Jx"^&_Xn

        <echo>${basedir}</echo>51Testing软件测试网^\_3U_(N S K2\R

        <echo>${ant.file}</echo>51Testing软件测试网U1h9o$RL ~/?TD#r(i/M H'D

        <echo>${ant.java.version}</echo>

xRgY|H&i\0

        <echo>${proname}</echo>51Testing软件测试网 IC\5S;V"GX^X

<!—编译javac标签-->

/t}4cf%Xqw0

<?xml version="1.0" encoding="UTF-8"?>51Testing软件测试网wu:x*y6Y-i

<projectname="javacTest"default="complie">

4j(?Iz$I0

      <propertyname="classes" value="build/classes"/>

!N L`W$W0gD0

     <propertyname="lib"value="./lib"></property>

#B2pId'tpBd,@0

      <targetname="clean">     51Testing软件测试网6pje1U{ZQ;f

        <deletedir="${lib}"/>

5` q$f3Zh0

         <deletedir="${classes}"/>51Testing软件测试网\9fAI1r&yZH

       </target>51Testing软件测试网$_:u5clwC*R

    <targetname="complie"depends="clean">     

EuB3V#Kv k6Z0

            <mkdirdir="${classes}"/>

:i{!r5qq0

       <javacsrcdir="src"destdir="${classes}"failonerror="true"debug="true"includeantruntime="true"fork="true"> 51Testing软件测试网e%r;iz(B|M l

          <!—设置src下包括以及不包括的文件模式-->51Testing软件测试网%q __2Qc#n1Y_

             <includename="/*Test*.java"/>51Testing软件测试网 FL;d.e/g0[

              <excludename="/Test*.java"/>51Testing软件测试网R6q:[8VF1z~-C

           </javac>

$O Y%B:~!z0

     </target>51Testing软件测试网@+S"[:q;Js5@

</project>51Testing软件测试网q^2~.O(Mov3e

<!—执行-java标签-->

3p'L3F;R]-z_@,E(Ff j0

  <targetname="run"depends="complie">

&? MWQ2?J8j2{0

   <mkdirdir="${lib}"/> 51Testing软件测试网5I u&y P#I|\\hk[y.}

      <javaclassname="HelloWorld"failonerror="true"classpath="${classes}"output="log/log.txt"append="true">      51Testing软件测试网{ e'fd B

  </java>   

A^!s0u bz&z0

 </target>

,`'BN!a-y`0

<!—jar包-jar标签-->

'ROh-tg W~+k0

<targetname="jar"depends="complie">51Testing软件测试网/O$F?:y_5XQ

       <mkdirdir="${lib}"/> 

yJxk-\G1_0

   <jardestfile="${lib}/helloworld.jar"basedir="${classes}">     

0u(V!MWu J|'b0

         <manifest>            51Testing软件测试网cj9QK$j fuq"^

            <attributename="Main-class"value="HelloWorld"/>     

s9iih+uv2O0

         </manifest>     51Testing软件测试网._Vl8b:@#I(b

     </jar>51Testing软件测试网:H"@M8gYLT$Q3Bv

   </target>51Testing软件测试网 nlh[#p4z ]&cn G

   <!—执行jarjava jar标签-->

TK&M2_DN i!t0

  <targetname="runjar"depends="jar">

!g-CY%P tpt0T:c0

       <javajar="${lib}/helloworld.jar"fork="true">     

nX+H/c/H s(xGr0

       </java>

}g/b3@l*q4t l]*u0

   </target>

%}"pZ }/UZY;H|q0

 ‘打war

!^1tX:e+K8g0

   <propertyname="build.dest"value=" WEB-INF/classes"/>   51Testing软件测试网 p[7z t+g#fH

  <target name="warFile" depends="compile"> 

'E4x3\,P)u$Po#Q`0

        <war destfile="${basedir}/${warFileName}" webxml="${basedir}/WebContent/WEB-INF/web.xml">

D)vyfN0

            <fileset dir="${basedir}/WebContent"> 

9X`U){0PpeIIIg'N w0

                <include name="**/**.*" /> 51Testing软件测试网 q4o&`:`U`u

                <exclude name="**/*.jar"/> 51Testing软件测试网S:y-bOw iV

                <exclude name="**/*.class"/> 

$a&E!QiX0

            </fileset> 

va#Ws7Eq']Wj6L0

            <lib dir="${basedir}/WebContent/WEB-INF/lib" /> 51Testing软件测试网.@.}-{Os F'jXE q.xE

            <classes dir="${build.dest}" /> 51Testing软件测试网&s d oy/kgQL$PXN

        </war> 51Testing软件测试网*TWV(B,z

    </target> 

9A[3beJ:t;w0

‘时间戳- tstamp标签,出现该标签则可以引用DSTAMP, TSTAMP, TODAY或自定义的日期格式51Testing软件测试网.P$xl*`L G*U

   <?xml version="1.0" encoding="UTF-8"?>51Testing软件测试网U(Z*uy;W

<projectname="javacTest"default="dateFormat">51Testing软件测试网A4{9`| ]5k Qz%W,a d

     <targetname="dateFormat">

_e*v.kJy"kC,R0

           <tstamp>51Testing软件测试网G'Jx4YJ/JT

      <!—自定义格式-->51Testing软件测试网z%F Y6{-T

           <formatproperty="mytime"pattern="yyyyMMddHHmmss"/> 51Testing软件测试网6f2Nvd#m`0Eh;n;|

       </tstamp>51Testing软件测试网@h9W#]wU8@

 <echomessage="${DSTAMP}"/>

2S G'`V1w-ns0

TAG:

 

评分:0

我来说两句

Open Toolbar