How to import an Ant "build.xml" that has a "build" task?

I imagine Gradle implicitly defines a “build” task. If I try to import an Ant “build.xml” that defines a “build” target, I get something like this:

FAILURE: Build failed with an exception.
  * Where:
Build file '==myhome==\git\atg\coherence_poc\build.gradle' line: 3
  * What went wrong:
A problem occurred evaluating root project 'coherence_poc'.
> Cannot add task ':build' as a task with that name already exists.

My “build.gradle” up to line 3 looks like this:

apply plugin:'java'
  ant.importBuild 'build.xml'

Is there any way to do a mapping on what I import, so it doesn’t conflict with the Gradle default task name?

Currently, you can’t define an include/exclude list of tasks you want to import. It’s either all or nothing. You might want to check out this posting to deal with task name clashes.