[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


This is a slight modification to Example 17.11, Ant target that depends on Gradle task, from the user manual:


ant.importBuild 'build.xml'

task intro << {
    println 'Hello, from Gradle'



    <!-- New target: -->
    <target name="indirect">

    <target name="hello" depends="intro">
        <echo>Hello, from Ant</echo>
        <antcall target="indirect" />

Output of gradle hello

Hello, from Gradle
[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.


Total time: 2.541 secs

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.


ant.importBuild 'build.xml'

task gradleTest << {
    println 'Gradle Test!'

test.dependsOn gradleTest


  <target name="indirect" depends="build,test"></target>

  <target name="doAll">
    <echo>Hello, from Ant</echo>
    <antcall target="indirect" />

  <target name="build">

  <target name="test">

Output of gradle doAll

[ant:echo] Hello, from Ant
[ant:echo] Build!
[ant:echo] Test!


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:

  • Checking that your issues contain requisite context, impact, behaviors, and examples as described in our published guidelines.
  • Leave a comment on the JIRA issue or open a new GitHub issue confirming that the above is complete.

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

Generated at Wed Jun 30 11:58:55 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.