svnExists | Ant condition that returns true if an element exists in the repository |
This document describes the conditions offered in svnant. To use those conditions, 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 conditions 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:
Ant condition that returns true if an element exists in the repository
Implementation: | org.tigris.subclipse.svnant.conditions.Exists |
---|
Attribute | Description | Required |
---|---|---|
target |
|
|
javahl |
|
|
svnkit |
|
|
This is a custom condition, as defined in the Ant documentation. A custom condition must be employed in conjunction with a <Condition> task to set a property.
This custom condition is used to determine if an element exists in the repository. The condition returns true if the element is known to te repository. It uses a process similar to "svn info" to determine the existence of an element. If "svn info" can return information about a file or a directory, then the svnExists condition should return true for such file or directory.
Example: determine if there exist a "build.xml" file for a project
<condition property="fileExists" value="true" else="false" > <svnExists javahl="${javahl}" svnkit="${svnkit}" target="http://svn.mycompany.com/project/trunk/build.xml"/> </condition> <echo>fileExists: ${fileExists}</echo>