Book Image

Gradle for Android

By : Kevin Pelgrims
Book Image

Gradle for Android

By: Kevin Pelgrims

Overview of this book

Table of Contents (16 chapters)
Gradle for Android
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Using Ant from Gradle


If you have invested a lot of time in setting up a build with Ant, the switch to Gradle might sound scary. In that case, Gradle cannot only execute Ant tasks, it can also expand them. This means you can migrate from Ant to Gradle in smaller steps, instead of spending several days on converting your entire build configuration.

Gradle uses Groovy's AntBuilder for the Ant integration. The AntBuilder enables you to execute any standard Ant task, your own custom Ant tasks, and entire Ant builds. It also makes it possible to define Ant properties in your Gradle build configuration.

Running Ant tasks from Gradle

Running a standard Ant task from Gradle is straightforward. You just need to prepend the task name with ant. and everything works out of the box. For example, to create an archive, you can use this task:

task archive << {
    ant.echo 'Ant is archiving...'
    ant.zip(destfile: 'archive.zip') {
        fileset(dir: 'zipme')
    }
}

The task is defined in Gradle, but...