Svn Conditions

Table of Content

svnExists Ant condition that returns true if an element exists in the repository

Introduction

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"/>
				
			

Bindings

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:

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.

svnExists

Ant condition that returns true if an element exists in the repository

Implementation: org.tigris.subclipse.svnant.conditions.Exists

Parameters

Attribute Description Required
target File name or URL to the element to be queried during the condition. Yes
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

No nested types defined for this type.

Description

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>