Execute ant build.xml with gradle

Hello gradle community,

I have ant multi-module project that is structured as following:
myProject → rootproject
----- subproject1
----- build.xml
----- subproject2
----- build.xml
I wanted to integrate gradle in myProject and juste reuse the build.xml file for compilation.
myProject now (after gradle integration) is containing:
build.gradle
settings.gradle
gradle.properties

how should I proceed to execute buid.xml of each subprjects using gradle (from build.gradle)?
I hope that my description is clear, please let me know if you need more details or more context

thank’s for your help :slight_smile:

I suppose, that the build.xml files in the sub-projects are existing ant-builds that you do not want to touch. Hence, I would try to do the following:

  1. Set up a gradle multi-project as depicted in A simple multi-project build. Especially, you’ll need only a settings.gradle in the base directory of “myProject” that contains the names of the sub-projects.
  2. In each subproject add a build.gradle containing the line “ant.importBuild ‘build.xml’” as described in Importing an Ant Build.

Now you sould be able to call “gradle <ant-target>” from the base directory and gradle will execute that ant target in all sub-projects.

Hello Detybear,

Thanks a lot for your support!
I managed to do it differently I just include subprojects in settings.gradle of the root project and just call gradle tasks only for the root project and execute throw a bash script the build.xml files.
It works as expected !

Thanks again for your support :blush: