svnFileSet | FileSet replacement that operates on list of files obtained from Subversion. |
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"/>
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:
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:
FileSet replacement that operates on list of files obtained from Subversion.
Implementation: | org.tigris.subclipse.svnant.SvnFileSet |
---|
Attribute | Description | Required |
---|---|---|
dir |
|
|
file |
|
|
includes |
|
|
excludes |
|
|
javahl |
|
|
svnkit |
|
|
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>
<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) { ... }
public void add(FileSet set) { addFileSet(set); }
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>