views:

3131

answers:

5

I have an Ant script that needs to checkout a directory from Subversion. This works using svnant/svnkit. However, Subversion access is authenticated, and I do not want to store my user password in a file.

Can I make svnkit pop up a password dialog? Or even better, make it use the same credential caching that subversive/svnkit inside of Eclipse uses (the username can be read from the build.properties)?

I cannot switch to public key based authentication, as I do not control the subversion server.

Right now, it just says "svn: authentication cancelled".

+2  A: 

To answer my own question, I can use the Ant [input] task to ask the user for a password and store it in a property that can be passed to the [svn] task.

 <target name="checkout">
    <input
        message="Please enter subversion password for ${username}:"
        addproperty="password"
      />

    <svn svnkit="${svnkit}" username="${username}" password="${password}">
     <checkout url="${urlRepos}/project" destPath="web/" />
    </svn> 
</target>

Unfortunately, this does not mask the password with * * * * *, and I still want to read from the credential cache...

Thilo
+2  A: 

The Jera Ant Tasks provide a [query] task that supports password input:

<taskdef name="query" classname="com.jera.anttasks.Query" />
<target name="checkout">
  <query
    message="Please enter subversion password for ${username}:"
    name="password"  password="true"
  />

  <svn svnkit="${svnkit}" username="${username}" password="${password}">
    <checkout url="${urlRepos}/project" destPath="web/" />
  </svn> 
</target>
Thilo
+1  A: 

Use ant-dialog (http://sourceforge.net/projects/ant-dialog/), it can display a java awt window so you can input properties. It also features a *** password like input field type.

gerald
+2  A: 

An analog to this answer:

<input message="password:>" addproperty="password">
      <handler classname="org.apache.tools.ant.input.SecureInputHandler" />
</input>

This will make it so that the person's username is not displayed. This requires Ant 1.7.1 or greater.

geowa4
A: 

All valid answers. But unfortunately the password is not crypted in the property. So if someone is able to edit your build.xml, he can echo or save your plaintext password in a textfile etc...

I'm looking for a possibility to provide a file, where i store my (somehow) encrypted password and read it (also encrypted) into an ant-property... Any suggestions?

Sauer
If someone can edit your build.xml, you are in all sorts of trouble. But yes, none of the answers so far address my original request to not prompt for the password at all, but use the existing subversion client credential cache.
Thilo