Apache Ant and SVN Integration

We could setup a SVN client in Apache Ant. Here is an example.

1. Download the following .jar files @ the repository.pentaho.org

  • svnant-1.3.0.jar
  • svnClientAdapter-svnant-1.3.0.jar
  • svnjavahl-svnant-1.3.0.jar

 

2. Put the above downloaded .jar files into a folder called ant-lib in your project webroot.

ant-for-example
  | - ant-lib
  |    | - svnant-1.3.0.jar
  |    | - svnClientAdapter-svnant-1.3.0.jar
  |    | - svnjavahl-svnant-1.3.0.jar
  | - build.xml

 

3. Edit the build.xml as follow:

<project name="ant-svn-example" default="run" basedir=".">

  <property name="svn_user" value="[your svn username]"/>
  <property name="svn_pass" value="[your svn password]"/>
  <property name="svn_path" value="[the svn path in your local machine]"/>

  <!-- Load the svnant lib -->
  <path id="svn_class_path">
    <pathelement location="${basedir}/ant-lib/svnant-1.3.0.jar"/>
    <pathelement location="${basedir}/ant-lib/svnClientAdapter-svnant-1.3.0.jar"/>
    <pathelement location="${basedir}/ant-lib/svnjavahl-svnant-1.3.0.jar"/>
  </path>
  <taskdef resource="org/tigris/subversion/svnant/svnantlib.xml" classpathref="svn_class_path"/>

  <target name="run">
    <svn username="${svn_user}" password="${svn_pass}">
      <status path="${svn_path}" revisionProperty="svn_version"/>
    </svn>
    <echo message="Current version: ${svn_version}"/>
  </target>
</project>

 

4. Try it out.
ant-svn-integration

You can also call svn checkout, update and other SVN client functions. For more information, you can refer to Tigris.org – svntask.

Done =)

Reference:

Advertisements

One thought on “Apache Ant and SVN Integration”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s