svntask examples for Apache Ant

A couple days ago I had my first experience with Apache Ant. If you have never heard of it before you should definitely check it out. Apache Ant is a very simple JAVA-based build tool with xml-based configuration files for automation.

I wanted to automate the process of importing/exporting specific MySQL database tables.In the next step I wanted to update and commit the data to SVN. After a quick research I found the JAVA lib svntask which is based on SVNKit very useful.

The only disadvantage in my opinion is that there is almost no documentation yet. To help other developers to get off on the right foot and save some time I’ll give some examples in the following section.

SVN update example:

<!-- SVN update -->
<target name="svn-update">
			force="false" recursive="false"

Optional arguments you can use are recursive(default: true) and force(default: true).

SVN add example:

<!-- SVN add -->
<target name="svn-add">

Optional boolean arguments are force, mkdir, climbUnversionedParents, includeIgnored and makeParents(default for all except mkrdir is true).

SVN commit example:

With version 1.0.7 authentication failed for me. So I added the username/password authentication to the commit class. You can get the temporary version here until the next update of svntask.

<!-- SVN Commit -->
<target name="svn-commit">
	<!-- don't store password in property files, use input  -->
		message="Enter SVN password:" 
			commitMessage="Test commit"
			username="user" password="${svn.password}"

Optional boolean arguments are keepLocks and force.

SVN ls update example:

<!-- SVN ls -->
<target name="svn-ls">

Optional argument is delimeter(default: , ).

SVN info example:

<!-- SVN info -->
<target name="svn-info">
	<!-- show revision, author and date -->
		value="At revision ${revisionVersion} by ${revisionAuthor} on ${revisionDate}" 
	<echo message="${version}"/>

I didn’t use log, status and switch so far. I will post examples if I will use it in the future.

Some useful links:
Apache Ant project:


  1. Nice work!

    You’re right, there is almost no svntask documentation.

    Would you be willing to tell me how to install svntask ?

    Thanks …John

  2. To install it, just drop svntask.jar and svnkit.jar into the lib folder of your ant installation.

    Then put this near the top of your build.xml file:

  3. Hi
    This is really great help from you.
    I am facing an issue what I need to do is check whether a(or multiple) file(s) if it is version-ed or not and if not then perform SVN add else perform SVN commit using SVNANT.

    Thanks in advance.

  4. Part of the instructions are missing. Since I’ve put both svnkit.jar and svntask.jar into the ANT_HOME/lib directory and then run the “svn-update” target.

    build.xml files on the line for , so something needs to define that. Document it here please. I suspect it is the missing part of Chris’s response.

  5. Is it possible to enter username and password for update?
    I get

    svn: Authentication required for ' Subversion realm'

    any solutions or suggestions to this?


  6. Below is one sample to get the latest header is assumed the svnkit.jar and svntask.jar are dropped in lib folder of ant

  7. hi .. how to get an un merged data as a daily report ?
    example : developers working on 50 files in branch but they merged only 20 files in svn trunk but remaining 30 files forgot to merged . Now is it possible to get that unmerged 30 files data as a daily report automatically ? please can anyone help me ..

  8. How to do a simple URL->URL copy??

    I’ve been looking in the javadoc and this tool doesn’t seems to have it implemented :(


Leave a Comment.