Using Ant from Gradle


I’m following this guide as a stepping stone to migrate an Ant build to Gradle. I’m using Gradle version 8.0. Using Ant from Gradle

I am trying to set the path on an AntBuilder instance but the method path does not exist on that instance. I’ve tried all the samples provided in the guide:

ant.path(id: 'classpath', location: 'libs')
ant.references.classpath = ant.path(location: 'libs')
ant.references['classpath'] = ant.path(location: 'libs')

Has that method been updated or is there another way to set the path on the instance? I’m happy to dig further if I’m missing something, thanks.

What is the error you are getting?
Can you share an MCVE?

This is the error

No candidates found for method call ant.path.

Where do you get that error?
If this is just in the IDE, try to actually execute the build.
If you are using Groovy DSL (which you do according to the syntax you showed) there are many things the IDE just cannot know due to the dynamic nature of the Groovy language.

Generally I highly recommend using Kotlin DSL instead. By now it is the default DSL, you immediately get type-safe build scripts, actually helpful error messages if you mess up the syntax, and amazingly better IDE support if you use a good IDE like IntelliJ IDEA or Android Studio.