Search code examples
xmlsvnantsvnant

SVN ANT "Add" Task with "force" Option Gives "is already under version control" build error


Using ANT and SVNANT, I want to check in a working directory that has a mix of svn-controlled files and new files and sub-directories. According to my understanding of the SVN ANT "add" task, using the "force" flag as I have below should do something similar to svn add --force *

Basically, I'm having the same issue described in this issue at the CollabNet site.

Here's my xml config:

<target name="add-new-files-to-test-repo" depends="check-out-projects">
    <svn username="${svn.test.username}" password="${svn.test.password}" svnkit="true" javahl="false">
        <add
            force="true" > 
            <fileset dir="${svn.testdir}"/>
        </add>
    </svn>      
    <echo message="Adding new files to SVN"/>
</target>

Gives the response:

svn: 'D:\Workspaces\TreXProjects\Build\testdir\New Text Document.txt' is already under version control

Solution

  • Finally got this working right after I wrote this, by re-reading the documentation I linked. As the part about using the "force" flag with the <add> task indicates:

    (applies only when dir attribute is set).

    So my fixed code reads:

    <target name="add-new-files-to-test-repo" depends="check-out-projects">
        <svn username="${svn.test.username}" password="${svn.test.password}" svnkit="true" javahl="false">
            <add force="true" dir="${svn.testdir}" >
            </add>
        </svn>      
        <echo message="Adding new files to SVN"/>
    </target>
    

    Of course, this means you can't use the <fileset> task's "include" attribute to skim for specific files, as the author of the issue linked in my question wanted to do. My work-around here is to check out the working directory from SVN, copy only the files I want into that working directory using a filtered and then that directory.