Search code examples
version-controlantcode-coveragegradleivy

Gradle: Ant-wards compatible?


I've had my eye on Gradle for a while now and am 99% convinced that I want to switch my builds over from Ant to it. However, before I invest this time, I need to be 100% sure that Gradle can do everything my Ant/Ivy builds already do (I can't lose any functionality):

  • Run code coverage tasks via Cobertura/JaCoCo
  • Run some Python scripts
  • Checkout/commit to a SVN repo
  • Run AnalytiX CodePro Ant tasks
  • Run pure Ant commands
  • Define my own tasks

I'm 99% sure about Python tasks as well as defining my own, but as for the rest I can't find any documentation on those sites that show they have Gradle tasks defined. If I can do all these thing I am bought and sold, otherwise I'm going to hold off until Gradle matures a little more. Thanks in advance!


Solution

  • You can use standard and custom Ant tasks in your Gradle build the way you are used to in Ant itself. Additionally, you can import existing Ant scripts. Targets of the imported Ant script get treated as first-class citizens so you can use them like any other Gradle task. As you can see you don't have to fully migrate your existing code to Gradle right away.

    It's as simple as this:

    ant.importBuild 'build.xml'