Subversion is a popular version control software and replacement for CVS, the grand-daddy of all version control software which is still widely used in open source community.颠覆罪是一个热门的版本控制软件和更换为个人简历,大-爸爸的所有版本控制软件仍然是广泛使用的开放源代码社区。

Recently I had the necessity to invoke Subversion commands like checkout from Ant, a popular java based build software which replaces make tool.最近,我有必要引用颠覆命令一样,结帐从蚂蚁,一个受欢迎的以Java为基础建立的软件取代,使工具。

There are two ant tasks to accomplish this, the better one is SvnAnt from Subclipse project.有两个蚂蚁任务,要做到这一点,更好地之一,是svnant从subclipse项目。 However configuring it to work was non-trivial as proper usage documentation was missing.不过,配置它的工作是不平凡的作为正确使用文件失踪。 So I decided simplify the process to make your life easier.所以我决定简化程序,使您的生活更轻松。

However the extensive commands it supports are well然而,广泛的命令,它支持良好 documented记录 .
Note: If prompted for user name / password use guest / guest.注意:如果提示用户名/密码使用客户/客户。

Why SvnAnt?为什么svnant ?
Subversion is a full-fledged version control software obviously supporting commands like checkout, add or commit.颠覆罪是一个完全成熟的版本控制软件显然是支持的命令一样,结帐,添加或承诺。 The ant task from O’Reily didn’t even support checkout!蚂蚁的任务从o'reily甚至没有支持结帐! It supported a very limited set from the available commands.它支持一个非常有限的一套从可用的命令。
So I went for所以我去 svnant task which had much better support.任务有很大的更好的支持。 Also this way you don’t have to mess with也通过这种方式,您不须一塌糊涂,与 exec’ing the Subversion CLI exec'ing颠覆的CLI commands directly from your ant script.命令直接从您的蚂蚁脚本。 It is wrapped up for ease of use.这是结束了为便于使用。 It can also use JNI interface for speed.它也可以使用jni接口的速度。

To provide access to the Subversion API, svnant uses either the提供进入颠覆空气污染指数, svnant用途,无论是 javahl - Subversion Java bindings or Subversion’s command line programs (which must be installed and in your PATH). -颠覆的J ava绑定或颠覆罪的命令行程序(必须安装并在您的路径) 。

javahl uses JNI which must be setup appropriately. javahl使用jni必须安装适当的。 I preferred using the Subversion’s command line programs as subversion was already installed in my system. i推荐使用颠覆的命令行程序作为颠覆已经安装在我的系统。

Steps:步骤:
1. 1 。 I am assuming you already have我假设您已经有 ant蚂蚁 installed.安装。 If not do it first.如果不能这样做第一。 Ensure %ANT_HOME% ($ANT_HOME for *nix) is defined and %ANT_HOME%\bin is appended to your %PATH%.确保% ant_home % (元ant_home为* nix中)的定义和% ant_home % \斌是附加到您的%路径% 。

2. 2 。 If you do not have subversion installed then first如果您没有颠覆安装,然后第一 download it下载 and install.并安装。

2.1 Ensure that svn is in your path by invoking svn from a command windows (cmd for windows, bash etc. for *nix). 2.1确保svn是在您的路径引用svn从命令窗口( cmd用于Windows ,在bash等* nix中) 。

3. 3 。 Download下载 svnant and extract the files to any directory.和文件提取到任何目录。

4. 4 。 Go to your project directory.转到您的项目目录。 If it doesn’t have a lib (or equivalent) directory to store required jar files then create one and copy all the files (*.jar ) from svnant’s lib directory:如果没有一个库(或同等学历) ,目录商店所需的jar文件,然后创建一个和所有文件复制( *.罐)由svnant的库目录:
commons-lang-2.0.jar商品郎2.0.jar
jakarta-regexp-1.3.jar雅加达- regexp的- 1.3.jar
svnClientAdapter.jar svnclientadapter.jar
svnant.jar
svnjavahl.jar

5. 5 。 To use svn task you have to add a taskdef to your build file.使用svn任务,你必须添加一个taskdef到您建立档案。 Use either of the following:使用下列任一:
Option 1:备选方案1 :

This requires the lib directory to be included with either “ant -lib lib” or by adding an extra parameter:这需要的lib目录中列入无论是“蚂蚁库库”或新增了额外的参数:

where project.classpath is previously defined as:凡project.classpath是以前的定义为:

Option 2 is simpler:方案2是简单的:

The project.classpath is previously defined as shown before.该project.classpath是先前定义显示之前。

For example you can use this simple build.xml file to fetch latest code from WordPress repository:例如,您可以使用这个简单的build.xml文件撷取最新的代码存放在WordPress :

Run this script by simply typing ant.运行此脚本,只需输入蚂蚁。

BTW: I think Subversion as version control software and ant as build and deployment software are two very strong products which should be part of any enterprise open source software stack.的BTW :我认为颠覆作为版本控制软件和蚂蚁作为建立和部署软件是两个非常强烈的产品应的一部分,任何企业开放源码软件堆栈。