ANT checkout task fails

2019-07-31 02:08发布

问题:

I've got the following markup:

<?xml version="1.0" ?>
<project name="SampleBuild" default="compile" basedir=".">
    <property name="SvnAntDir" value="C:/Program Files/Apache/svnant-1.2.1/doc" />  
    <property name="src" value="_src_" />
    <property name="build" value="_build_"/>
    <property name="dist" value="${build}/_jars_" />    

    <path id= "svnant.classpath" >
        <fileset dir= "${SvnAntDir}" >
            <include name= "*.jar" />
        </fileset>
    </path>

    <target name="pre-cleanup">
        <delete dir="${src}" />     
        <delete file="${dist}/Project.jar" />
        <delete includeEmptyDirs="true" failonerror="false">
            <fileset dir="${build}/_classes_/sevgok/" />
        </delete>

        <mkdir dir="${src}" />
        <tstamp />
    </target>

    <target name="checkout" depends="pre-cleanup">      
        <typedef resource="org/tigris/subversion/svnant/svnantlib.xml" classpathref="svnant.classpath" />       
        <svn>
            <checkout url="svn://p-subversion/Project/trunk" revision="HEAD" destPath="${src}" />
        </svn>
    </target>   

    <target name="compile" depends="checkout">
        <javac srcdir="${src}" destdir="${build}/_classes_" debug="on" debuglevel="lines,vars,source">
            <classpath>
                <pathelement path="${classpath}" />
                <fileset dir="./_libs_">
                    <include name="*.jar" />
                    <include name="*.zip" />
                </fileset>
            </classpath>
        </javac>
    </target>   
</project>

Problem occurs when trying to make a build. The error message is next:

checkout: [svn] <Checkout> started ...
[svn] svn: svn://p-subversion/Project/trunk` doesn't exist
[svn] svn: svn://p-subversion/Project/trunk` doesn't exist
[svn] <Checkout> failed!

Build FAILED
C:\build.minimal.xml: (line of code which points to <svn> openning tag): Can't checkout.`

Simultaneously it is possible to make a checkout with Tortoise SVN client using the url.

Help!

EDIT

I tried using -v key when building and got the following:

Caused by: org.tigris.subversion.svnclientadapter.SVNClientException: org.tigris .subversion.javahl.ClientException: svn: URL 'svn://p-subversion/Project/trunk ' doesn't exist

EDIT

Is there any alternative to SvnAnt? It would be great if it was also well documentated.

Thanks

EDIT

So code that works for me is:

<target name="checkout" depends="pre-cleanup">
    <exec dir="${basedir}" executable="svn" failonerror="true">
        <arg line="checkout -r ${revision} ${SvnUrl} ${src}" />
    </exec>
</target>

where ${SvnUrl} is the same URL I used before.

回答1:

If svnant does not work at all you could just execute svn from the command line:

<exec executable="svn" dir="DIRECTORY_WHERE_COMMAND_EXECUTES">
  <arg line="checkout svn://p-subversion/Project/trunk $src"/>
</exec>

You would have to install a svn command line client. Make sure, that you add the bin-Directory of the client to the PATH.
But take care to install the same client version as your tortoise client. If they mismatch they will make the working copy unaccessible for the other.



回答2:

What is p-subversion supposed to be? SVN URLs, just like HTTP URLs, begin with a hostname. If p-subversion isn't a hostname that will point to your computer, then the checkout will fail. Perhaps it should look more like this?

svn://localhost/p-subversion/Project/trunk

[edit]If it's a Windows share...

file://p-subversion/Project/trunk

the svn:// URL assumes a hostname, but in the case of a share some other part of the OS is already negotiating the TCP connection. Refer to it like you would any other folder.