3

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".

Thilo
  • 257,207
  • 101
  • 511
  • 656

4 Answers4

4

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.

Community
  • 1
  • 1
geowa4
  • 40,390
  • 17
  • 88
  • 107
3

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
  • 257,207
  • 101
  • 511
  • 656
2

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
  • 257,207
  • 101
  • 511
  • 656
1

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.