Dependency Sequence Lost Between Ant Target and Gradle Task

(neil) #1

I would like to checkout a tag from SVN and then build an RPM. I’ve written the checkout as a Gradle task, and the RPM build is in an existing Ant target. I want the Gradle task to precede the Ant target. Here are the definitions:


ant.importBuild "build.xml"
task checkout << {

Ant (build.xml)

<target name="build-tarball" depends="build-war">
<target name="build-rpm" depends="checkout,build-tarball">

When I run the Ant target build-rpm from Gradle, I want the Gradle checkout task to run, then the build-tarball Ant target, and then the build-rpm target. Unfortunately, checkout never happens, and build-tarball (with its dependencies) starts running. Naturally it fails.

Any insight into how to get the dependency sequence to be honored is appreciated.


(Peter Niederwieser) #2

You are hitting a known limitation of Gradle’s Ant import. Soft dependencies between Ant targets are not retained because Gradle does not currently have such a concept. Instead you can add a hard dependency (‘tasks.“build-tarball”.dependsOn(checkout)’). If necessary, you can do so conditonally, for example only when ‘build-rpm’ is invoked on the command line.