n4rzul
n4rzul

Reputation: 4078

gradle project dependencies using ant files to build

We have a custom build application that was built and leverages ant. This application, call it Bob reads an xml file to understand the interproject dependencies.

I have the following project file/directory structure.

--root
|--P1
|--P2
|--P3
|--P4

Each project (except root) has a build.xml file. So Bob's interproject dependency xml file might look as follows:

 <project name="P1">
 </project>

 <project name="P2">
  <dependencies>
    <dependsOn name="P1"/>
  </dependencies>
 </project>

 <project name="P3">
  <dependencies>
    <dependsOn name="P2"/>    
  </dependencies>
 </project>

 <project name="P4">
  <dependencies>
    <dependsOn name="P2"/>    
    </dependencies>
 </project>

</projects>

So the dependency tree as you can see would look like so

--root
  |P1
    |--P2
       |--P3
       |--P4

To build each project with ant you simply invoke the build target. If you tell Bob to build P3 it knows to invoke ant for each project in order P1, P2 then P3.

What is the simplest way to use Gradle's ant.importBuild 'builder.xml' and define the above project structure so that the build order is always right?

I do not want to restructure the directories to make this work please.

Upvotes: 0

Views: 531

Answers (1)

Peter Niederwieser
Peter Niederwieser

Reputation: 123890

You would have to define a multi-project Gradle build, and wire the Ant targets (which become Gradle tasks after import) as needed. However, you would end up with a legacy Gradle build that resembles your legacy Ant build and misses out on most of Gradle's advantages. You are much more likely to achieve a good and lasting result if you bite the bullet and port the build to Gradle. The ported build could still occasionally reuse Ant tasks where truly needed, but should not import any Ant scripts.

Upvotes: 1

Related Questions