Best practice to reuse ant for Gradle build?

My current ant build contains about 50 task in the build.xml. How I can reuse the current ant build for Gradle build.

build.xml:
..
 <target name="pack1"/>
...
 <target name="pack2"/>
..
 <target name="packN"/>
...
  build.gradle:
ant.importBuild 'build.xml'
...

I can run build like that: gradle pack1 etc How I can run the build for all tasks?

If there is a best practice, it’s not to use ‘ant.importBuild’ and only reuse Ant tasks (and only when there is no Gradle equivalent). Otherwise you’ll be missing out on many of Gradle’s advantages. Also, ‘ant.importBuild’ has known limitations.

How I can run the build for all tasks?

You can do something like:

task packAll {

dependsOn tasks.matching { it.name.startsWith(“pack”) }

}

Thank you!