Svn Types

Table of Content

svnFileSet FileSet replacement that operates on list of files obtained from Subversion.

Introduction

This document describes the type extensions that svn-ant brings to Ant. To use those types, you must first obtain a copy of svnant.jar, add it to the classpath of your ant project and define the types. Fortunately, there is a resource file, within the distributed JAR file, and all those steps can be accomplished with the following code:

				
<path id="svnant.classpath">
  <pathelement location="${svnant.dir}/lib/svnant.jar" />
  <pathelement location="${svnant.dir}/lib/svnClientAdapter.jar" />
</path>  

<typedef resource="svntypes.xml" classpathref="project.classpath"/>
				
			

If you are upgrading from an earlier version of svnAnt, and the following line was used in your build.xml file, then replace it with the ones above.

				
<taskdef resource="svntask.properties" classpathref="svnant.classpath"/>
				
			

Bindings

All types offer two parameters: javahl and svnkit. Those parameters are booleans, which means their values can be set to either true or false. If not specified, those parameters are assumed to be set (true). These two parameters are used to select which client is used to access Subversion.

There are three clients used by svnAnt to access Subversion:

To better understand the difference between those three clients, please refer to documentation on svnClientAdapter.jar.

The property javahl is considered only if the javahl libraries are available. Similarly, the property svnkit is considered only if SVNKit is present. Finally, javahl takes precedence over svnkit.

To better illustrate the previous paragraph, use the following steps:

  1. If javahl is true and JavaHL bindings are available, then JavaHL is used.
  2. If svnkit is true and SVNKit is present, then SVNKit is used.
  3. If the two previous tests failed, for any reason, then the Command Line Interface is used.

svnFileSet

FileSet replacement that operates on list of files obtained from Subversion.

Implementation: org.tigris.subclipse.svnant.SvnFileSet

Parameters

Attribute Description Required
dir Specifies the root directory used by the file set. It should specify a directory managed by Subversion. Either dir or file must be specified
file If used, specifies a fileset that contains a single file. Either dir or file must be specified
includes Comma-seperated or space-separated list of patterns, which describe files that are included. If this attribute if not specified, then all files are included. No
excludes Comma-seperated or space-separated list of patterns, which describe files that are excluded. If this attribute if not specified, then no files are excluded. No
javahl If set, instructs the use of JavaHL bindings, if available. Set to false to use command line client interface to subversion. Defaults to true. See note for more details. No
svnkit If set, instructs the use of SVNKit bindings, if available. Set to false to use command line client interface to subversion. Defaults to true. See note for more details. No

Nested Types

exclude

The type svnFileSet can include the nested type 'exclude', similar to a classic FileSet.

include

The type svnFileSet can include the nested type 'include', similar to a classic FileSet.

patternSet

The type svnFileSet can include the nested type 'patternSet', similar to a classic FileSet.

selector

The type svnFileSet can include the any file selector, such as contains, date size, or any file selector defined by svn-ant

Description

This type implements a FileSet. Instances of FileSet are used in tasks that operates on a number of files. The files selected by a FileSet can be tailored by a number of patterns and selectors. More information about file sets is available with the Ant documentation.

The motivation with creating a replacement FileSet that is based on Subversion was to have the ability of creating sets of files that include deleted and missing files. In fact, the classic fileset operates only on files that are reported by the file system and can not predict deleted and missing files. Furthermore, there are useful commands that can be performed on deleted and missing files, such as 'revert', 'delete', 'update' and others.

At the present time, svnFileSet is experimental. It supports selectors but it does not yet accept any patterns (include, exclude). Those enhancments are to come later.

svnFileSet can be used within any svn-ant task that supports a nested file sets. It can also be used in any task that is based on a file set. If you have a problem using svnFileSet within a task that works well with the classic fileset, then report the problem to the author of the task. However, for the time being, there is a work around your problem. Instead of using a svnFileSet directly in the targeted task, use it indirectly via a classic fileset and a reference. For example, if ANT complains about a task similar to the following:


<target name="example">
	<mkdir dir="test"/>
	<copy todir="test">
		<svnFileSet dir="workingcopy">
			<svnAdded/>
		</svnFileSet>
	</copy>
</target>
					
				
you can rewrite it, using a reference, as:

<target name="example">
	<svnFileSet id="svnFileSetId_1" dir="workingcopy">
		<svnAdded/>
	</svnFileSet>
	<mkdir dir="test"/>
	<copy todir="test">
		<fileset refid="svnFileSetId_1"/>
	</copy>
</target>
					
				

If you are the author of a fileset-based task and that you can not understand why your task does not accept svnFileSet while it works perfectly well with the classic fileset, here is a thing you can check. If your task accepts instances of FileSet with a method similar to:


public void addFileset(FileSet set) {
	...
}
					
				
then adding the following method should fix the problem:

public void add(FileSet set) {
	addFileSet(set);
}
					
				

Examples

The following ant script can be used to remove all missing files from the associated repository:


<svn>
	<delete>
		<svnFileSet dir="workingcopy">
			<svnMissing/>
		</svnFileSet>
	</delete>
	<commit 
		dir="workingcopy" 
		message="automatically removing missing files"/>
</svn>
					
				

The following ant script can be used to add all new files to the associated repository:


<svn>
	<add>
		<svnFileSet dir="workingcopy">
			<svnUnversioned/>
		</svnFileSet>
	</add>
	<commit
		dir="workingcopy" 
		message="automatically adding files"/>
</svn>
					
				

The following ant script can be used to restore all deleted files:


<svn>
	<revert>
		<svnFileSet dir="workingcopy">
			<svnDeleted/>
		</svnFileSet>
	</revert>
</svn>
					
				

If, in the previous example, you wanted svn-ant to use the command line adapter:


<svn javahl="false" svnkit="false">
	<revert>
		<svnFileSet 
			dir="workingcopy" 
			javahl="false" 
			svnkit="false">
			<svnDeleted 
				javahl="false" 
				svnkit="false"/>
		</svnFileSet>
	</revert>
</svn>