Overview

   JWare/AntXtras Subversion for Ant (Svn4Ant) is a complete set of native Ant tasks for managing Subversion working copies, exported directories, and repositories from a build, test, or deployment environment.

100% Subversion

All of the expected client operations exist in Svn4Ant: checkout, commit, update, stat, mkdir, add, delete, revert, status, property edit, cat, copy, move, import, export, and more. And because Svn4Ant uses SvnKit, an all-Java Subversion library, it is not a limited wrapper of an external Subversion client and does not require any operating system libraries to perform any of its client operations. Depending on the Svn4Ant version you download, you can have access to the latest Subversion 1.5.x and 1.6.x features[3.0+] or to the tried-and-true functions of Subversion 1.4.x.

While the majority of Svn4Ant components focus on client commands, Svn4Ant also contains support for many admin operations for both types of Subversion repositories, fsfs and bdb. The admin operations Svn4Ant supports are: (repository) create, hotcopy, dump, load, setlog, and verify. Unlike client operations, admin operations might require operating system (OS) libraries to implement their functions depending on the target repository’s type; for example, if you want to create a BerkeleyDB based repository using Svn4Ant, you will have to ensure that the OS-specific Berkeley libraries are available to Ant.

100% Ant

Svn4Ant is designed to operate as an integral part of an Ant-based system. Svn4Ant leverages and enhances many of the standard Ant features to make its components function as natural extensions to the builtin Ant components. Some of these special Svn4Ant features include:

  • Repository and working copy related conditions and selectors
  • Working copy related resource collections[3.0+]
  • Repository and working copy access function shortcuts
  • Use of standard path-like structures to describe files, directories, and search paths

Workflow Value-Add

Svn4Ant goes beyond just bringing Subversion commands to Ant. Svn4Ant also gives you a collection of advanced functions so you can implement more complex build and deployment requirements from within your Ant-based system. Some of Svn4Ant’s additional features include:

  • Credential management that precludes the storage of sensitive information in Ant properties.
  • Support for creating older version working copies without forcing upgrades.
  • Support for deep copies that includes moving of relative links.
  • Support for true snapshots and branches that includes pinning of all links to specific revisions.
  • Support for wholesale export of disparate directory trees merged with local modifications.
  • Support for the import of vendor packages including packages that are tarred, zipped, or bzipped.
  • Support for change lists and patch generation[3.0+].
AntXtras Based!

:!: Svn4Ant is part of the AntXtras family of Ant extensions and includes the core AntXtras components in its distribution. These core components alone are a powerful value-add to any Ant-based system as they include support for sophisticated execution-rules, flow-control, and function shortcuts. Svn4Ant provides the same consistency in its component’s interfaces that all AntXtras components possess. Read the AntXtras/Foundation Overview for more information about AntXtras.

Svn4Ant Component Summary

Client Components

For an complete description of all client components, their parameters, and usage examples read the User Guide. If you want to load the Svn4Ant client antlib into its own namespace, use “jwaresoftware.svn4ant.client” and “svn:” as the namespace URI and prefix (these are presumed for most of the documentation on this website). Read the Svn4Ant Properties page for the list of OS and Java properties that control Svn4Ant. If you’re a developer looking to extend or use Svn4Ant in your own Ant components, you will find additional implementation details in the Svn4Ant Javadoc API reference.

Task/Type General Description
svn:credential,
svn:server,
svn:serverset
Lets you define your repository connection information including credentials. Svn4Ant supports both plaintext username, password credentials and SSL based keyfiles and pass phrases. Svn4Ant can also (re)use locally cached credentials from other Subversion clients.
svn:import Lets you import a new directory tree or third-party archive (tgz, zip, etc.) into a repository.
svn:add Lets you add files and directories to a working copy.
svn:checkout Lets you checkout a working copy of a repository directory tree.
svn:cat Lets you extract the contents of a single file under Subversion control to a local file or other Ant fixture element like a property or variable.
svn:copy Lets you create a copy of an item already under Subversion control. Relative links are left untouched.
svn:revert Lets you undo local changes you have performed to one or more files or to a directory.
svn:update Lets you update one or more working copies to specific revisions.
svn:delete Lets you remove one or more items from under Subversion control.
svn:move Lets you move one or more items already under Subversion control. External and relative links are left untouched.
svn:commit Lets you commit local changes to the repository.
svn:export Lets you export a repository directory tree to a local area or archive (tgz, zip, etc.).
svn:clean Lets you remove all items not under Subversion control from a working copy.
svn:branch Lets you do a deep copy of a repository directory tree while pinning external references and moving relative links.
svn:retire Lets you create a frozen copy of a repository directory tree. Aka ‘make a tag’. Relative links are properly moved to new location.
svn:prop Lets you manipulate Subversion meta properties on files and directories. Svn4Ant also provides a set of presets of this base component for specific property operations; for example: svn:propset and svn:proplist.
svn:svn Lets you execute all Subversion client commands using standard Ant command line argument parameters including those for which there is no Svn4Ant equivalent like ‘mkdir’, ‘stat’, and ‘info’.
svn:revget Gives you the revision of a working copy or repository item.
svn:dirname Gives you the name of the working copy Subversion directory (.svn, _svn, etc.)
svn:libcheck Gives you the version of SvnKit and Svn4Ant you’ve loaded into your Ant runtime.
Admin Components

For an complete description of all admin components, their parameters, and usage examples read the User Guide. If you want to load the Svn4Ant admin antlib into its own namespace, use “jwaresoftware.svn4ant.admin” and “svnadmin:” as the namespace URI and prefix (these are presumed for most of the documentation on this website). Just like the standard Subversion admin tools, the Svn4Ant admin components work only on local (reachable via the filesystem) repositories.

Task/Type General Description
svnadmin:create Lets you create a new local Subversion repository. Svn4Ant supports both fsfs and bdb repository types.
svnadmin:setlog Lets you change the log message associated with a particular repository revision.
svnadmin:hotcopy Lets you create a full “hot” backup of your repository, including all hooks, configuration files, and, of course, database files.
svnadmin:dump Lets you create a full or incremental dump of your repository.
svnadmin:load Lets you load a previously created dump file into a new or existing repository.
svnadmin:verify Lets you verify the integrity of your repository.

Quick Start Examples

• You can install the Svn4Ant package directly into your <ANT_HOME>/lib directory but more typically, you will install it into its own location. This example assumes the latter case; it loads the Svn4Ant client antlib into the Ant runtime from a location defined by the ‘SVN4ANT_HOME’ property and then links its components to the “svn:” namespace prefix.

 1: <project name="example" xmlns:svn="jwaresoftware.svn4ant.client">
 2:   <property name="SVN4ANT_HOME" value="..."/>
 3:
 4:   <taskdef uri="jwaresoftware.svn4ant.client"
 5:     resource="org/jwaresoftware/svn4ant/client/antlib.xml">
 6:     <classpath>
 7:       <fileset dir="${SVN4ANT_HOME}/dep">
 8:         <include name="*/lib/*.jar"/>
 9:       </fileset>
10:       <fileset dir="${SVN4ANT_HOME}/lib">
11:         <include name="jw-svn4ant.jar"/>
12:       </fileset>
13:     </classpath>
14:   </taskdef>
15:


• Define your Subversion credentials for re-use by all Svn4Ant tasks:

1: <svn:server id="my.repo" isdefault="yes" authcache="no">
2:   <url value="http://svn.example.com/"/>
3:   <credential username="myuserid" password="mypasswd"/>
4: </svn:server>


• Create a new working copy of ‘myproject/trunk@HEAD’:

1: <svn:checkout from="myproject/trunk" to="${work.dir}"/>


• Update an existing working copy:

1: <svn:update path="${work.dir}"/>


• Get the revision a working copy represents for use in a build label:

1: <svn:revget path="${work.dir}" property="build.reporev"/>


• Add all new local files to a working copy and immediately commit the additions.

1: <svn:add path="${work.dir}" commit="yes">
2:   <message>Initial setup with configuration</message>
3: </svn:add>


• Commit a changed working copy:

1: <svn:commit path="${work.dir}">
2:   <message>The reason for changes…</message>
3: </svn:commit>


• Create a branch of ‘myproject/trunk@1234’ in preparation for a release.

1: <svn:branch credential="all.repos" revision="1234"
2:      from="myproject/trunk"
3:      to="myproject/branches/${branch.name}"
4:      message="Branch for myproject release ${branch.name}"/>


• Create a checkpoint (tag) of ‘myproject/branches/${branchname}@HEAD’:

1: <svn:branch credential="all.repos"
2:      from="myproject/branches/${branchname}"
3:      to="myproject/checkpoints/${branchname}-review3"
4:      message="Checkpoint for ${branchname} peer review 3"/>


• Export a local working copy with modifications as a standalone tarred and gzipped archive:

1: <svn:export from="${work.dir}"
2:      to="${ftp.dir}/website-${BSTAMP}"
3:      addlocals="yes" externals="yes"
4:      controls="+tar+gzip+sha1"/>


• Create a new Subversion project with this Ant macrodef <mksvnproject>1):

 1: <macrodef name="mksvnproject">
 2:   <attribute name="name"/>
 3:   <attribute name="username" default="admin"/>
 4:   <attribute name="password" default="${$password:admin}"/>
 5:   <attribute name="repo" default="${$svnurl:my.repo}"/>
 6:   <sequential>
 7:     <svn:svn action="mkdir" username="@{username}" password="@{password}">
 8:       <argument value="@{repo}/@{name}"/>
 9:       <argument value="@{repo}/@{name}/trunk"/>
10:       <argument value="@{repo}/@{name}/checkpoints"/>
11:       <argument value="@{repo}/@{name}/branches"/>
12:       <argument value="@{repo}/@{name}/releases"/>
13:       <argument line="-m ‘Created’"/>
14:     </svn:svn>
15:   </sequential>
16: </macrodef>


• Import a local directory tree as the starting point for a new project and immediately checkout.

1: <svn:import from="${projects.dir}/myproject"
2:       to="myproject" checkout="yes"
3:       message="Created" revisionproperty="myproject.rev0"/>


• Move a release branch into the readonly release area ‘myproject/releases’.

1: <svn:retire credential="all.repos"
2:      from="myproject/branches/${branch.name}"
3:      to="myproject/releases/${branch.name}"
4:      message="Retired ${product.longname} ${branch.name}"/>


• Copy contents of remote Subversion controlled files into local (temporary) files with Ant property substitution.

 1: <svn:cat>
 2:   <item from="build/dist-build.number" tofile="build/build.number"/>
 3:   <item from="build/dist-build.import" tofile="build/build.import">
 4:     <filterchain>
 5:       <expandproperties/>
 6:       <replacetokens begintoken="#" endtoken="#">
 7:          <token key="DATE" value="${TODAY}"/>
 8:          <token key="VCSID" value="${build.reporev}"/>
 9:       </replacetokens>
10:     </filterchain>
11:   </item>
12: </svn:cat>


• Update the log message associated with a build revision that failed its subsequent integration smoke test.2)

 1: <do true="${$anyset:smoketest.incomplete,smoketest.failed}">
 2:   <svn:revpropget path="${buildundertest}" revision="${buildrev}" tovar="last.log">
 3:     <property name="svn:log"/>
 4:   </svn:revpropget>
 5:   <assign var="last.log" op="+s" value=" (FAILED [SMOKE])"/>
 6:   <svn:revpropset path="${buildundertest}" revision="${buildrev}">
 7:     <property name="svn:log" value="${$var:last.log}"/>
 8:   </svn:revpropset>
 9: </do>


1) Requires you to load the AntXtras antlib for function shortcut support.
2) Requires you to load the AntXtras antlib for variables, flow control, and function shortcut support.

Navigation
Personal Tools