Ant的常用方法例子
1. javac
- <path id="base.path">
-
- <pathelement location="${lib.dir}/log4j-1.2.16.jar" />
-
- </path>
-
- <target name="complie"depends="clean">
-
- <javac srcdir="${src.dir}" destdir="${dest.dir}" classpathref="base.path"includeantruntime="on"/>
-
- <echo message="complie source successfully." />
-
- </target>
2. Delete, mkdir, and echo
- <target name="clean" >
-
- <delete dir="${dest.dir}" />
-
- <delete file="${lib.dir}/safx.jar" />
-
- <mkdir dir="${dest.dir}" />
-
- <echo message="clean and remake classes dir successfully." />
-
- </target>
3. Copy
- <p style="background: rgb(240, 240, 240);"><target name="copylog4j"depends="complie"></p><p style="background: rgb(240, 240, 240);"> <copy todir="${dest.dir}"></p><p style="background: rgb(240, 240, 240);"> <fileset dir="${src.dir}"></p><p style="background: rgb(240, 240, 240);"> <includenameincludename="log4j.properties" /> </p><p style="background: rgb(240, 240, 240);"> </fileset></p><p style="background: rgb(240, 240, 240);"> </copy></p><p style="background: rgb(240, 240, 240);"> <echo message="copylog4j.properties file successfully." /></p><p style="background: rgb(240, 240, 240);"></target></p>
4. Jar
- <target name="jar"depends="copylog4j">
-
- <jar destfile="${lib.dir}/safx.jar" basedir="${dest.dir}" />
-
- <delete dir="${dest.dir}" />
-
- </target>
5. Zip
- <target name="zip">
-
- <echomessageechomessage="zip start..." />
-
- <copy todir="D:/picture">
-
- <fileset dir="${dir.output}"includes="${dir.screenshot}/*.png" />
-
- </copy>
-
- <copy file="log4j_file.html"tofile="${dir.output}/log4j_file.html" />
-
- <zip destfile="${dir.report}/${CREATE_TIME}_${global.browser}_${global.version}.zip"basedir="${dir.output}" includes="*.html"excludes="${dir.screenshot}/*.png" update="true" />
-
- <zipd estfile="${dir.report}/${CREATE_TIME}_${global.browser}_${global.version}_${dir.screenshot}.zip"basedir="${dir.output}" excludes="*.html"includes="${dir.screenshot}/*.png" update="true" />
-
- <echo message="zip end..." />
- </target>
6. Email
- <targetnametargetname="email">
-
- <echo message="email start..." />
-
- <mail mailhost="${mail.host}" mailport="${mail.port}"subject="${CREATE_TIME} The ${global.version} build has completed"ssl="on" charset="utf-8" user="${mail.user}"password="${mail.password}" messagemimetype="text/html">
-
- <from address="${mail.user}" />
-
- <message>The${global.version} build has completed.</message>
-
-
- <to address="caiqcong@126.com" />
-
-
- <fileset dir="${dir.report}">
-
-
- <includenameincludename="${CREATE_TIME}_${global.browser}_${global.version}.zip" />
-
-
- </fileset>
-
- </mail>
-
- <echomessageechomessage="email end..." />
-
- </target>
7. SVNcheckout
- <target name="svn.checkout" depends="svn.checkout.prepare">
-
- <echo message="svn.checkout start..." />
-
-
-
- <svn javahl="true" username="${svn.username}"password="${svn.password}">
-
-
-
- <checkouturlcheckouturl="${svn.url}/account" destPath="account"revision="HEAD" />
-
- <checkouturlcheckouturl="${svn.url}/email" destPath="email"revision="HEAD" />
-
- <checkouturlcheckouturl="${svn.url}/import" destPath="import"revision="HEAD" />
-
-
- <checkouturlcheckouturl="${svn.url}/${svn.dir.schema}"destPath="${svn.dir.schema}" revision="HEAD" />
-
- <checkouturlcheckouturl="${svn.url}/${svn.dir.testCase}/${global.version}"destPath="${svn.dir.testCase}/${global.version}"revision="HEAD" />
-
- <checkouturlcheckouturl="${svn.url}/${svn.dir.webSite}/2.0.24"destPath="${svn.dir.webSite}/2.0.24" revision="HEAD" />
-
- </svn>
-
- <echomessageechomessage="svn.checkout end..." />
-
- </target>
|