使用svn提供的工具svnant可以很方便的用Ant从svn检出代码,主要代码如下:
<project name="check out from SVN use ant" default="checkout">
<!-- define the svn url and the local directory to be checked out -->
<property file="build.properties" />
<path id="ant.classpath"> <pathelement location="${ant_home}/lib/svnant.jar"/> <pathelement location="${ant_home}/lib/svnClientAdapter.jar"/> <pathelement location="${ant_home}/lib/svnjavahl.jar"/> </path> <!-- define the svn task--> <taskdef name="svn" classname="org.tigris.subversion.svnant.SvnTask" > <classpath refid="ant.classpath"/> </taskdef> <!-- prepare for the checking out:clean the directory --> <target name="prepare" description="Prepare the dirs for the task"> <delete dir="${local.dir}" /> <mkdir dir="${local.dir}" /> </target>
<!-- check out the scource from the svn --> <target name="checkout" depends="prepare"> <svn javahl="true" username="" password="" > <checkout url="${svn.url}" destPath="${local.dir}" /> </svn> </target>
</project>
svn.url=svn://9.186.57.111/ariadne/main/IP-client local.dir=C:/SVNTest
一个简单的例子(包含svnant.zip)可以从http://download.youkuaiyun.com/source/534499下载。 更多帮助请访问:http://subclipse.tigris.org/svnant.html
另外在配置文件中定义svn的地址和要check到的本地地址