Use Subclipse Svn Task in Ant scripts

Install

* First, install SVN command line tool. I used SlikSVN for Win32 from Slik SVN download site.
* Download svnant.jar from http://subclipse.tigris.org/svnant.html. I downloaded stable release 1.0.0 from this link.
* Unzip.
* Include two jar files in the CLASSPATH

set SVNANT_LIB=c:\svnant-1.0.0\lib
set CLASSPATH=%SVNANT_LIB%\svnant.jar;%SVNANT_LIB%\svnClientAdapter.jar;

* Define svn task in build.xml file

<path id="svn.ant.path">
    <pathelement location="${svnant.jar}"/>
    <pathelement location="${svnClientAdapter.jar}"/>
</path>
 
<typedef resource="svntask.properties" 
    classpath="svn.ant.path" />

* Use ant task

<target name="zip.src" 
  description="Zip up source code for deployment">
  <echo>${svn.tmp.dir}</echo>
  <delete dir="${svn.tmp.dir}" />
  <svn javahl="false">
      <export 
          srcUrl="${svn.url}"
          destPath="${svn.tmp.dir}"
      />
  </svn>
  <property name="src.zip.file" location="c:/temp/mysrc.zip"/>
  <delete file="${src.zip.file}"/>
  <zip basedir="${svn.tmp.dir}" 
      destfile="${src.zip.file}" 
      excludes="doc/**" 
      />
</target>

References

* Svn Task

This entry was posted in svn. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


*

This site uses Akismet to reduce spam. Learn how your comment data is processed.