How to get the SVN info use ANT

来源:互联网 发布:sql object id 编辑:程序博客网 时间:2024/05/18 00:26

1.How to get the SVN info

There are two ways to get the SVN info:

Ø     Add some tags in one file and hope SVN willupdate them, but if this file is not get updated, it the tag will not changedneither, and we are not sure how to get those values though java codes.

Ø     The other one is retrieve the info at thebuilding stage using ant task, and store them into one specified files, andread those files when needed.

 

There are two options when we choose the second approach.

1Exec ”svn.exe” in Subversion Client  folder

Pre-condition:

You must install Command-line SVN (CollabNet) firstly. Downloadfrom http://www.collab.net/downloads/subversion/.

Maybe TortoiseSVN(Download from:  http://tortoisesvn.net/downloads)and setup the user accounts is also a must, because this ant task doesn’t needto input any user info.

 

<property file="local.properties" />

 

<target name="generate_svn_info" description="generate an info file which contains the svn info">

      <exec dir="${SVN_HOME}" executable="${SVN_CLIENT_HOME}/svn.exe" output="svn_info.txt" >

           <arg line="info" />

      </exec>

</target>

 

Below is a sample generated by this script

Path: .

URL: http://xxxxxxxxxxxxx/xxxxxxxxxxxxx/xxxxxxxxxxxxx

Repository Root: http://xxx/xxxxx/xxxx

Repository UUIDxxxx-xxx-x-x-x-x-x-xxxx-xxxxx:

Revision: 41454

Node Kind: directory

Schedule: normal

Last Changed Author: xxxxx

Last Changed Rev: 41453

Last Changed Date: 2010-10-20 08:29:46 +0800 (Wed, 20 Oct 2010)

 

2 Use ant jar files provide by CollabNet

Use the ant jar files provided by CollabNet (Download from: http://subclipse.tigris.org/servlets/ProjectDocumentList?folderID=1731&expandFolder=1731&folderID=0).The shortages are we need to include new jar files and we need to set theusername and password in the build script.

<path id="svnant.lib" >

        <fileset>

            <include name="svnant.jar"/>

            <include name="svnClientAdapter.jar"/>

            <include name="svnjavahl.jar"/>

        </fileset>

</path>

   

<taskdef name="svn" classpathref="project.classpath" classname="org.tigris.subversion.svnant.SvnTask" />

 

 

<target name="ant_generate_svn_info">

    <svn username="xxxx" password="xxxxxx">

       <status urlProperty="http://axxxx/xxxx/xxxxxx/xxxx" path="." revisionProperty="svn.revision" />

    </svn>

   

    <echo>lastChangedRevisionProperty ${svn.revision}</echo>

</target>

 

 

原创粉丝点击