What is Gradle? (comparison of gradle vs ant vs make)

‹ Android SQLiteOpenHelper onUpgrade() | What is Groovy? ›

Gradle is a build tool similar to make or ant which is being adopted by the Android project as a replacement for ant scripts and the automated "build" step in Eclipse.

There's a useful book about Gradle available online for free at http://www.gradleware.com/registered/books/building-and-testing/

Here is a comparison between gradle and two other commonly used build tools:

Gradle Ant GNU Make
Default build file name build.gradle build.xml Makefile
Unit of work "task" "target" "target"
Build file syntax Gradle Build Language (Groovy with language extensions) XML makefile
Example syntax

defaultTasks 'hello'
task hello (dependsOn: [dependency1, dependency2, ...]){
  doLast {
    command1
    command2
    ...
  }
}

<?xml version="1.0" encoding="UTF-8"?>
<project default="hello">
  <target name="hello" depends="dependency1, dependency2, ...">
    <command1 />
    <command2 />
    ...
  </target>
</project>
target: dependency1 dependency2 ...
    command1
    command2
    ...
Written in Groovy Java C
Time to run a target that prints "Hello" 2235 ms 476 ms 4.175 ms

Timing methodology

I used the current default versions of gradle (1.0~m3-1), ant (1.8.2-4build1), and make (3.81-8.1ubuntu1.1) from Ubuntu 12.04.3. The shell syntax is zsh. In each case, I ran the "repeat" command several times before starting measurement in an attempt to pre-warm all binaries and the build file into memory, and then ran the "repeat" command 10 times and averaged the results.

Gradle

defaultTasks 'all'
task all {
  doLast {
    println 'Hello'
  }
}

% time (repeat 10 gradle) >& /dev/null

Ant

<?xml version="1.0" encoding="UTF-8"?>
<project default="all">
  <target name="all">
    <echo message="Hello" />
  </target>
</project>

% time (repeat 100 ant) >& /dev/null

Make

all:
    echo "Hello"

% time (repeat 1000 make) >& /dev/null

Subscribe to All Posts - Wesley Tanaka