[GRADLE-1571] Ant target that depends on Gradle task breaks if Ant target includes <antcall>. Created: 23/May/11 Updated: 06/Feb/17 Resolved: 06/Feb/17 |
|
Status: | Resolved |
Project: | Gradle |
Affects Version/s: | 0.9.2 |
Fix Version/s: | None |
Type: | Bug | ||
Reporter: | Mark Jeffcoat | Assignee: | Unassigned |
Resolution: | Duplicate | Votes: | 6 |
Description |
This is a slight modification to Example 17.11, Ant target that depends on Gradle task, from the user manual: build.gradle ant.importBuild 'build.xml' task intro << { println 'Hello, from Gradle' } build.xml <project> <!-- New target: --> <target name="indirect"> </target> <target name="hello" depends="intro"> <echo>Hello, from Ant</echo> <antcall target="indirect" /> </target> </project> Output of gradle hello :intro Hello, from Gradle :hello [ant:echo] Hello, from Ant FAILURE: Build failed with an exception. * Where: Build file '/home/jeffcoat/projects/WLE75-1/src/sample/build.gradle' * What went wrong: Execution failed for task ':hello'. Cause: Target "intro" does not exist in the project "wle". It is used from target "hello". * Try: Run with -s or -d option to get more details. Run with -S option to get the full (very verbose) stacktrace. BUILD FAILED Total time: 2.541 secs |
Comments |
Comment by Mark Jeffcoat [ 23/May/11 ] |
Also tested on 1.0-milestone-3 with the same result. |
Comment by Scott Resnik [ 09/Mar/16 ] |
antcall also breaks any task dependencies added in the gradle build that imported the ant build. build.gradle ant.importBuild 'build.xml' task gradleTest << { println 'Gradle Test!' } test.dependsOn gradleTest build.xml <project> <target name="indirect" depends="build,test"></target> <target name="doAll"> <echo>Hello, from Ant</echo> <antcall target="indirect" /> </target> <target name="build"> <echo>Build!</echo> </target> <target name="test"> <echo>Test!</echo> </target> </project> Output of gradle doAll :doAll [ant:echo] Hello, from Ant [ant:echo] Build! [ant:echo] Test! BUILD SUCCESSFUL Total time: 1.883 secs Notice that the gradleTest target was not executed. Antcall effectively bypasses the gradle ant runner environment. This was with gradle 2.10. |
Comment by Steffen Yount [ 03/May/16 ] |
It looks like ant.importBuild() first uses the org.apache.tools.ant.ProjectHelper to parse the build file into an ant project object. Then it adds new gradle tasks and gradle task dependencies to the gradle project for all of the ant targets found in that ant project object. The <antcall target="..."> ant tasks are not being converted into any kind of gradle aware surrogate during this ant.importBuild() process. I suspect that as a consequence these 'antcall' tasks actually invoke the ant targets found in the otherwise defunct ant project object rather than invoking the gradle tasks found in the gradle project, and thus they escape the gradle project's context and have no ability to reference, resolve, or depend on gradle tasks in the gradle project. |
Comment by Benjamin Muschko [ 15/Nov/16 ] |
As announced on the Gradle blog we are planning to completely migrate issues from JIRA to GitHub. We intend to prioritize issues that are actionable and impactful while working more closely with the community. Many of our JIRA issues are inactionable or irrelevant. We would like to request your help to ensure we can appropriately prioritize JIRA issues you’ve contributed to. Please confirm that you still advocate for your JIRA issue before December 10th, 2016 by:
We look forward to collaborating with you more closely on GitHub. Thank you for your contribution to Gradle! |
Comment by Steffen Yount [ 16/Nov/16 ] |
I believe this bug still presents a big hole in Gradle's Ant compatibility layer. |
Comment by Benjamin Muschko [ 06/Feb/17 ] |
The issue is now tracked here: https://github.com/gradle/gradle/issues/1341 |