ANT与SVN集成

需求描述:从SVN服务器检出最新代码,编译,打包,发布测试环境。

解决方案:使用ANT官网提供的扩展工具中的svnant检出代码。


环境介绍:

操作系统:windows 7 64bit

ant版本:apache-ant-1.9.3

svnant版本:svnant-1.2.1


准备工作:

1.下载ANT

A.访问:http://ant.apache.org/   

B.home——>Download——>Binary Distributions

C.下载合适的安装包即可,这里下载windows版本的

2.下载SVNANT

A.访问:http://ant.apache.org/   

B.home——>Documentation——>External Tools and Tasks

C.点击URL,进入http://subclipse.tigris.org/svnant.html

D.下载svnant

3.配置JAVA环境变量

4.配置ANT环境变量


集成步骤:

一、引入svnant的类库

在build.xml中加入如下配置

<path id="svnant.classpath">
	<fileset dir="D:/software/svn/svnant-1.2.1/lib" includes="**/*.jar"/>
</path>

二、定义svn的命令

<typedef resource="org/tigris/subversion/svnant/svnantlib.xml" classpathref="svnant.classpath" />

三、调用svn命令

<target name="updateFromSVN" description="从SVN更新代码">
		<svn javahl="false" svnkit="true" username="${svnUserName}" password="${svnPwd}">
			<checkout revision="HEAD" url="${svnURL}/web" destPath="${projectRoot}/ROOT"/>
			<checkout revision="HEAD" url="${svnURL}/src" destPath="${projectRoot}/build/src"/>
		</svn>
</target>
关于这里以checkout为例,其他命令请访问http://subclipse.tigris.org/svnant.html查看。


原文地址:https://www.cnblogs.com/pengyan5945/p/5218307.html