1. Key code, get time
<tstamp><format property= "Touch.time" pattern= "Yyyy/mm/dd hh:mm"/></tstamp>
2. Get the local SVN version
<target name= "version" depends= "init" > <typedef resource= "Com/googlecode/svntask/svntask.xml" > <classpath> <fileset dir= "${lib}" ><include name= "Svnkit.jar"/><include name= "Svntask.jar "/> </fileset></classpath> </typedef> <svn><info path=" E:\worksapce2\ ACService2 "revisionproperty=" revisionversion "/> </svn> <property name=" version "Value=" ${ Revisionversion} "/>
<echo message= "version: ${version}"/></target>
3. Project examples
<project name= "build_pub" default= "Jar" basedir= "." ><property name= "Class.dir" value= "web-inf/classes"/><property name= "src.dir" value= "src"/>< Property Name= "Build.dir" value= "Targetjar"/><property name= "Jar.name" value= "Ac-api.jar"/><property Name= "Lib" value= "Web-inf/lib"/><path id= "classpath" ><fileset dir= "${lib}" includes= "**/*.jar"/> </path><target name= "Init" ><echo message= "+---init start---+"/><tstamp/><delete file= "$ {build.dir}/${jar.name} "/><echo message=" +---init end---+ "/></target><target name=" version " depends= "Init" ><typedef resource= "Com/googlecode/svntask/svntask.xml" ><classpath><fileset dir= "${lib}" ><include name= "Svnkit.jar"/><include name= "Svntask.jar"/></fileset></classpath ></typedef><svn><info path= "E:\worksapce2\ACService2" revisionproperty= "Revisionversion"/> </svn><property name= "version"Value=" ${revisionversion} "/><echo message=" version: ${version} "/></target><target name=" Jar " depends= "Version" ><echo message= "+---jar *.class files start---+"/><tstamp><format property= " Touch.time "pattern=" Yyyy/mm/dd hh:mm "/></tstamp><pathconvert property=" Mf.classpath "pathsep=" lib/" ><path refid= "Classpath"/><flattenmapper/></pathconvert><jar destfile= "${build.dir}/${ Jar.name} "update=" true "><fileset dir=" ${class.dir} "includes=" com/inspur/api/ac/**,com/inspur/api/common/* * "></fileset><manifest><attribute name=" User-name "value=" Liyx "/><attribute name=" Svn-version "value=" ${version} "/><attribute name=" Package-time "value=" ${touch.time} "/></manifest> </jar><echo message= "+---jar *.class files End---+"/></target></project>
4. Precautions
Pay attention to the direct dependency of target, and get the local SVN number depends on the local jar package, respectively, Svntask.jar and Svnkit.jar, respectively, I share:
Http://mobile.qzone.qq.com/l?g=1357&sharekey=7ab0de0e131e16e9d859dff5bc1c5ea9
http://mobile.qzone.qq.com/l?g=1357&sharekey=cdbeb37e11b4395fd3dad86edc02e197
Ant script hits jar package auto get time and Project SVN version number