Tech and Media Labs
This site uses cookies to improve the user experience.

Gradle Tutorial

Jakob Jenkov
Last update: 2015-08-04

Gradle is a build tool similar to Maven and Ant. If you are a Java developer you will most likely have used either Ant or Maven already. Gradle is the latest of these three build tools, and Gradle is starting to get wider adoption (at the time of writing in 2015).

Some of the advantages Gradle has over Maven and Ant is more concise build scripts and a more flexible build script language. One disadvantage Gradle has is that it is incredibly slow! (come on, Gradle devs, you can do better than that!).

Gradle Version

This Gradle tutorial is based on Gradle 2.5.

Gradle is Implemented in Groovy

Gradle is implemented using Groovy, and Gradle build scripts are actually Groovy scripts. Groovy is a programming language that runs on the Java Virtual Machine (JVM).

That Gradle scripts are Groovy scripts doesn't mean that you have to program every build script from the bottom up. Gradle comes with a sensible set of defaults which makes it reasonably fast to write a basic Gradle script.

Gradle Core Concepts

To better understand Gradle I will briefly explain the core concepts of Gradle. The Gradle core concepts are:

  • Projects
  • Tasks
  • Build scripts

A project is typically some software you want to build. Tasks are actions needed to build the project. A task could be compiling the source code, generating JavaDoc, zipping the compiled classes into a JAR file etc. A Gradle project contains one or more tasks to execute in order to build the project.

A project typically has a build script in which its tasks are defined. The build script is used by the gradle command so it can know what tasks are defined for the project.

The build script is typically called build.gradle and is normally located in the root directory of the project you are building. When the gradle command is executed it looks in the directory which the command is executed in, for the build script to execute.

You will see projects, tasks and build scripts mentioned again and again in the following texts in this Gradle tutorial.

Getting Started With Gradle

To get started using Gradle you must first install Gradle. Installing Gradle is covered in the next text in this Gradle tutorial.

Jakob Jenkov

Copyright  Jenkov Aps
Close TOC