Gradle ant target/task name collision

I’m trying to Gradle-ize our build by using Gradle to execute our existing Ant build. I’m using the java plugin so I can set source/target and I’m using ant.importBuild ‘build.xml’ to import our existing Ant build file. When I execute Gradle, I get this error: “Cannot add task ‘:myproject:test’ as a task with that name already exists”. I understand that both Ant and Gradle have these targets/tasks in common: clean, jar, javadoc, test and there’s a collision in the namesj, but I’m trying to figure out how to solve this problem… One option is to change the Ant target names in my build.xml, but I cannot do this right now as our existing build infrastructure depends on the existing target names. I found this “wrapper” solution (, but this did not work for me. How can I solve this?

Your options are:

  • Do not apply the Java plugin to the same project that imports the Ant build (what’s the purpose of this?). * Rename the conflicting Ant targets (in the Ant build script).

you find where is ant sdk build.xml and edit task name clean to clean_ant.

i use gradle from android studio, i coppy file build.xml from android sdk to edit name clean, then link reference gradle to file coppied ant.

Task is not exist.