How to get the SVN info use ANT

本文介绍了两种获取SVN版本信息的方式:一种是在文件中添加标记并期望SVN更新;另一种是在构建阶段使用Ant任务检索信息,并将这些信息存储在指定文件中以便随时读取。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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 will update them, but if this file is not get updated, it the tag will not changed neither, and we are not sure how to get those values though java codes.

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

 

There are two options when we choose the second approach.

1 Exec ”svn.exe” in Subversion Client  folder

Pre-condition:

You must install Command-line SVN (CollabNet) firstly. Download from 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 need to 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 the username 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 >

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值