Thanks for the detailed response and suggestion. I will try it and post in the forum.
From: Spencer Allain <[email protected]<mailto:[email protected]>> Reply-To: "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>> Date: Tue, 20 Mar 2012 12:52:43 -0500 To: "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>> Subject: Re: [gradle-user] Dependency Sequence Lost Between Ant Target and Gradle Task Ant targets get turned into native gradle tasks build-rpm depends on checkout and build-tarball build-tarball depends only upon build-war Gradle does not attempt to preserve Ant's partial ordering logic of C depends on A "then" B, so it gets treated as C depends on A "and" B such that A and B just need to be run in any order before C. Ant lets you do "interesting" things, like C depends on A, C; and D depends on B, C, A so that running "ant C" runs things in the A,B,C order, but running "ant D" will run them in B,A,C,D. So that if C really needs B and A run in the other order to function properly, that constraint is not satisfied. Now, sometimes that ad-hoc ordering adjustment by invoking D is what you want, but generally not. With your example, gradle will always run build-tarball first, because as an arbitrary tie-breaker, it (currently) uses alphabetical ordering to determine which to run first, but in the future it will likely run both tasks in parallel. A solution (not necessarily a great one) is to see what tasks are explicitly being asked to be invoked from the user's command line. In the gradle build file (somewhere after the ant.importBuild line) you would do something like: 'build-rpm' { if (gradle.startParameter.taskNames.contains(name)) { 'build-tarball'.dependsOn 'checkout'} if (gradle.startParameter.taskNames.contains(path)) { 'build-tarball'.dependsOn 'checkout'} } This will only catch direct invocations of build-rpm or :build-rpm as part of the command line tasks, so it is a bit fragile, but does provide conditional dependency adjustments for individual tasks that are specialized like this. You might consider raising this question in the forums, since there is more traffic there for user questions. -Spencer ________________________________ From: Neil Chaudhuri <[email protected]<mailto:[email protected]>> To: "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>> Sent: Tuesday, March 20, 2012 12:38 PM Subject: [gradle-user] Dependency Sequence Lost Between Ant Target and Gradle Task 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: Gradle ant.importBuild "build.xml" task checkout << { … } Ant (build.xml) <target name="build-tarball" depends="build-war" description="Create the source tarball used to create the RPM."> … </target> <target name="build-rpm" depends="checkout,build-tarball"> … </target> 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. Thanks.
