How do I force gradle to fetch dependencies?

I have a bit of Gradle code that queries the checked-out SVN sandbox for its SVN revision, using svnant and svnClientAdapter:

configurations {
    svnConf
}
  dependencies {
    svnConf "org.tigris:svnant:1.3+"
    svnConf "org.tigris:svnClientAdapter:0.9+"
}
  ant {
    taskdef(resource: 'org/tigris/subversion/svnant/svnantlib.xml',
            classpath: configurations.svnConf.asPath)
}

…and some more stuff.

This works fine if I’m using a local repository, but it fails when using a remote repository like Maven or Artifactory. Gradle doesn’t fetch those jar files before it runs the ant taskdef, which of course fails. I could put all this code into a task, and make that task depend on svnConf; but the whole point of this code is to set properties on the project itself (like project.version), so I think I need this code to run before the execution phase.

Bottom line: How can I make Gradle retrieve the jar files for svnConf right away, so I can run that taskdef?

There is no need to force anything because asPath will do this automatically. There is likely some other problem like repositories not being declared correctly.

That explanation seems increasingly likely as we look into this further; thanks.

Hi Chris,

If you’re still watching this thread and are willing / allowed to share how you got this working, I’d be very grateful.

TIA, Ryan

We’re storing our jar files locally, rather than grabbing them from Maven or Artifactory. So it’s really a non-issue for us. Also, I seem to recall that Peter was right and we had a different misconfiguration in our build system somewhere.

I can’t believe I made such a vague request. My apologies. I was actually wondering how you’re pulling the SVN revision from the local sandbox.

// Read the current revision from SVN.
  // Set up the classpath and (ant) taskdef for the svn lib.
configurations {
    svnConf
}
  dependencies {
    svnConf "org.tigris:svnant:1.3+"
    svnConf "org.tigris:svnClientAdapter:0.9+"
}
  ant {
    taskdef(resource: 'org/tigris/subversion/svnant/svnantlib.xml',
            classpath: configurations.svnConf.asPath)
}
  ant {
    svnSetting(id: 'svnSettings', javahl: 'false', svnkit: 'false')
    svn(refid: 'svnSettings') {
        info(target: rootDir.path)
    }
}
// Extract the last path component of the SVN URL. This will
// be either trunk or the branch/tag name.
rootProject.svnBranchName = ant.properties['svn.info.url'].split('/').last()
assert rootProject.svnBranchName.length() > 0
  // Execute the svnversion command as an external process, and
// parse its output.
new ByteArrayOutputStream().withStream { os ->
    exec {
        executable = 'svnversion'
        args = [rootDir.path]
        standardOutput = os
    }
    rootProject.svnRevision = os.toString().trim().replace(':', '-')
}

This will set rootProject.svnBranchName to the name of the current branch of “trunk”, and rootProject.svnRevision will be the the output of svnversion.

I believe I had to compile one of these svn libs from source, because they haven’t released a version since SVN 1.7 was released.

That looks like exactly what I was hoping for. Thank you very much!