Gradle is an open-source build automation tool focused on flexibility and performances. It builds upon the concepts of Apache Ant and Apache Maven and introduces a Groovy-based domain-specific language (DSL) instead of the XML form used by Apache Maven for declaring the project configuration.

Gradle was designed for multi-project builds, which can grow to be quite large. It supports incremental builds by intelligently determining which parts of the build tree are up to date; any task dependent only on those parts does not need to be re-executed. Below are some of the best features of Gradle:

  • Highly customizable — Gradle is modelled in a way that customizable and extensible in the most fundamental ways.

  • Fast — Gradle completes tasks quickly by reusing outputs from previous executions, processing only inputs that changed, and executing tasks in parallel.

  • Powerful — Gradle is the official build tool for Android, and comes with support for many popular languages and technologies.

In this guide, we will explain how to install Gradle on a CentOS 7 server.

To install Gradle on Ubuntu 16.04, you can follow the guide here

Deploying your cloud server
If you have not already registered with Cloudwafer, you should begin by getting signed up. Take a moment to create an account after which you can easily deploy your own cloud servers.

Once you have signed up, log into your Cloudwafer Client Area and deploy your Cloudwafer cloud server.

Updating System Packages
It is always recommended that you update the system to the latest packages before beginning any major installations. This is done with the command below:

sudo yum update

Prerequisites: Gradle requires a Java JDK version 7 or higher to run. You can check here on how to install Java on CentOS 7 if you don't have it installed. To check the version of Java that is currently set as the default, issue the command below:

java -version

Step 1: Download and install Gradle
As at the time of writing this guide, the current Gradle release is version 6.5. The distribution zip file comes in two flavours: Binary-only and Complete (all with docs and sources). We are going to download and install the Binary-only flavour for the purpose of this guide.

wget https://services.gradle.org/distributions/gradle-4.10.2-bin.zip

Step 2: Unpack the distribution

  • Create a directory for the Gradle installation

    sudo mkdir /opt/gradle
    
  • Extract the downloaded archive to the newly created directory.

    unzip -d /opt/gradle gradle-4.10.2-bin.zip
    

  • You can view the contents of the directory using the command below:

    ls /opt/gradle/gradle-4.10.2
    

Step 3: Configure your system environment
For running Gradle, firstly add the environment variable GRADLE_HOME. This should point to the unpacked files from the Gradle website (the directory of the unzipped distribution)

export PATH=$PATH:/opt/gradle/gradle-4.10.2/bin

This is done in order for Gradle to be executable anywhere on the system.

Step 4: Verifying installation
Issue the command below to run Gradle and display the version

gradle -v

You have successfully completed the Gradle installation.