Ant script hits jar package auto get time and Project SVN version number

Source: Internet
Author: User
Tags echo message

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.