How to Install Gradle on CentOS 7

Install Gradle on CentOS 7

In this article, we will have explained the necessary steps to install and configure Gradle on CentOS 7. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

Gradle is a free and open source build automation toolset based on the concepts of Apache Ant and Apache Maven. Unlike its predecessors which use XML for scripting, Gradle uses Groovy, a dynamic, object-oriented programming language for the Java platform to define the project and build scripts.

Install Gradle on CentOS

Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.

sudo yum clean all
sudo yum update

Step 2. Install OpenJDK.

Gradle requires Java to be installed on your system. To install OpenJDK 8 run following command in terminal:

sudo yum install java-1.8.0-openjdk-devel

To verify that Java was successfully installed, run the following command:

$ java -version
openjdk version "1.8.0_192"
OpenJDK Runtime Environment (build 1.8.0_192-b12)
OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)

Step 3. Install Gradle.

First, download Gradle from official Gradle release page. The latest Gradle version available is 5.1:

wget -P /tmp

Now unzip downloaded zip file using following command:

sudo unzip -d /opt/gradle /tmp/

Step 4. Setup environment variables.

Next step is to configure the PATH environment variable to include the Gradle bin directory. To do so, open your text editor and create a new file named inside of the /etc/profile.d/ directory:

sudo nano /etc/profile.d/
export GRADLE_HOME=/opt/gradle/gradle-5.0
export PATH=${GRADLE_HOME}/bin:${PATH}

Now make script file executable using following command:

sudo chmod +x /etc/profile.d/

Load the environment variables using following command:

source /etc/profile.d/

Step 5. Verify Installation.

To verify if Gradle is installed properly use the gradle -v command which will display the Gradle version:

$ gradle -v
Welcome to Gradle 5.1

Here are the highlights of this release:
 - Kotlin DSL 1.0
 - Task timeouts
 - Dependency alignment aka BOM support
 - Interactive `gradle init`

For more details see

Gradle 5.0

Build time:   2019-07-26 11:48:43 UTC
Revision:     7fc6e5abf2fc5fe0824aec8a0f5462664dbcd987

Kotlin DSL:   1.0.4
Kotlin:       1.3.10
Groovy:       2.5.4
Ant:          Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM:          1.8.0_192 (Oracle Corporation 25.191-b12)
OS:           Linux 3.10.0-862.14.6.el7.x86_64 amd64

Congratulation, you have learned how to install and configure Gradle on CentOS 7. If you have any question, please leave a comment below.