user1980193
user1980193

Reputation: 11

Checking out a specific folder from SVN using ANT

I could use ANT to checkout my code from SVN. But now I would like to do a checkout only of some of the folders, and not all of them. Say my SVN has Folder1, Folder2 and Folder3, but I wish to checkout only Folder1 and Folder2. Is there a method to do it using ANT?

Upvotes: 0

Views: 633

Answers (2)

David W.
David W.

Reputation: 107080

You can use Ant to checkout your code, but I don't like doing that.

First, there's the issue of checking out the build.xml, so you can run it in order to checkout the rest of the code. And what if my checkout updates build.xml itself?

My contention is that Ant should be used for building and you let other tools that can do things better do their thing.

To do what you want, you can use the following command lines:

svn co --depth=none $REPO_LOCATION
svn up --set-depth=infinity Folder1
svn up --set-depth=infinity Folder2

This could be put into a Windows batch script or a Unix shell script, or even inside an Ant build file:

<exec executable="svn">
    <arg line="co --depth=none ${env.REPO_LOCATION}/>
<exec/>
<exec executable="svn"
    <arg line="up --set-depth=infinity Folder1"/>
</exec>
<exec executable="svn"
    <arg line="up --set-depth=infinity Folder2"/>
</exec>

There is a Subversion ant task plugin, but it can be tricky to get it to work, and I believe it just executes the SVN command directly anyway.

Upvotes: 0

thekbb
thekbb

Reputation: 7924

A few questions first. Why use ant? you could also do it in COBOL - it doesn't make it a good idea. Generally I find that using ANT to deal with source smells bad. The ant file should be in source control, so you have a chicken/egg paradox problem - how do you check out the code without the code?

Why do you want to checkout a subset of folders in your project? It sounds like you may benefit from changing the layout of your repositories. Are Folder1, Folder2 and Folder3 unique projects that should have their own branches, tags and trunk? There are a number of decent questions and answers about svn layout here on SO. In general if Folder1 and Folder2 are not released together, they're different svn projects.

Now to answer your question: you'd not be able to checkout a subset of directories at the same level with svnant checkout, or using the exec task to call the svn client you'd have to do separate checkouts for Folder1 and Folder2

Upvotes: 2

Related Questions