tags:

views:

91

answers:

2

Hi there,

I'm looking to create a directory using SVN ANT, but only so if the directory does not already exist (using the mkdir nested task with SVN ANT appears to fail if you specify a directory that already exists).

Is there a isExists flag or something of that ilk that I can use here? Or something else I can use to detect existing directories on an SVN repository before I continue with creating my directories via an ANT script?

Any thoughts on this would be much appreciated.

Cheers,

Stuart

A: 

The available task enables you to set a property dependent on the existence of a file or directory

<available property="desired-dir-exists" file="src/desired_dir"/>

<target name="mkdir" unless="desired-dir-exists">
    <svn>
        <mkdir path="src/desired_dir"/>
    </svn>
</target>
Mark O'Connor
He's referring to the SvnAnt task, not "plain ant"
Grodriguez
A: 

Two options:

  1. You can set the failonerror attribute to false. This way if the directory exists, an error message will be printed but the build will not be aborted.

    <svn failonerror="false">
        <mkdir path="..." message="..."/>
    </svn>
    
  2. If you want to avoid the error message you will probably need to do something more elaborate, such as performing a checkout / update first, then examine your working copy to see if the directory you want to create already exists.

Grodriguez
OK thanks for feedback guys, I'll give your suggestions a try.
sjwb