Ant closures no longer working in 7.6?


I used to use the ant closure syntax to execute ant tasks in my gradle file, i.e.

  copy (...)

This seems to no longer work with Gradle 7.6. I get a non-informative error message:

> Problem: failed to create task or type call
  Cause: The name is undefined.
  Action: Check the spelling.
  Action: Check that any custom tasks/types have been declared.
  Action: Check that any <presetdef>/<macrodef> declarations have taken place.

“ant.copy” syntax still works. Is this an intended change (i.e. deprecated and phased-out way), a bug or an error on my side?

Thanks in advance,

I strongly wonder why you use the copy Ant task actually as there is a much better Gradle alternative, but I’m just assuming that was not the real-life example but just an arbitrary example.

This was a (hopefully) unintended side effect of Add ability to use closure-like methods on props by octylFractal · Pull Request #21242 · gradle/gradle · GitHub which causes the ant builder to try to find the task call now incorrectly and fails in finding it. You should open an issue about this regression in 7.6.

Hi Björn,

indeed the copy was only an example. We moved our projects from Ant to Gradle and still have some third-party Ant-Tasks in our build process, e.g. the “wsimport” from JAXWS. Btw, the copy task of Ant is still handy, I have to admit, while I used the Gradle version also in the past.
I am going to open an issue, I’ll refer to the pull request you mentioned. Thanks for your help.


Edit: the issue is #23111

1 Like