How to Install Gradle on CentOS 7

In this article, We are going to perform How to Install Gradle on CentOS 7 or any other cloud platform like AWS EC2, Azure VM, Google Compute Cloud, etc., with preinstalled CentOS 7.

Introduction

Gradle is Free and Open Source build automation tool. It is used to build any type of language code.

Prerequisites

  • CentOS 7 with minimal installation
  • SSH access with sudo privileges

Install wget and unzip if not installed

$ sudo yum install wget
$ sudo yum install unzip

Install JDK on CentOS

you can install OpenJDK 8 or 11.

$ sudo yum update
$ sudo yum -y install java-1.8.0-openjdk

OR

Install OpenJDK 11

$ sudo yum install openjdk-11-jdk

Lets verify java version

$ java -version

Output:

$ java -version
java version "1.8.0_231"
Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)

Install Gradle on CentOS 7

Here we are downloading and installing Gradle 6.4 Version, if you want to download latest version go through Gradle Download page.

Download the gradle setup in /tmp directory using below command,

$ cd /tmp
$ sudo wget https://downloads.gradle-dn.com/distributions/gradle-6.4.1-bin.zip

unzip the gradle binary setup in /opt/gradle directory

$ unzip -d /opt/gradle gradle-6.4.1-bin.zip

Configure Environment Variable

To configure the environment variable open the below file:
$ sudo nano /etc/profile.d/gradle.sh
Paste the below path into the file:
/etc/profile.d/gradle.sh
export PATH=$PATH:/opt/gradle/gradle-6.4.1/bin

Load the environment variable using below command

$ source /etc/profile.d/gradle.sh

We have configured environment for gradle.

Verify Gradle Version

Now verify the Gradle version using below command.

$ gradle -v

Output:

------------------------------------------------------------
Gradle 6.4.1
------------------------------------------------------------

Build time: 2020-05-15 19:43:40 UTC
Revision: 1a04183c502614b5c80e33d603074e0b4a2777c5

Kotlin: 1.3.71
Groovy: 2.5.10
Ant: Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM: 11.0.7 (Azul Systems, Inc. 11.0.7+10-LTS)
OS: Linux 5.4.0-1009-aws amd64

Conclusion

In this article, We have covered How to Install Gradle on CentOS 7, Configure environment variable for Gradle, verify gradle version.

Related Articles:

How to Install Java on Ubuntu 20.04 LTS

Reference

Gradle Official link

FOSS TechNix

FOSS TechNix (Free,Open Source Software's and Technology Nix*) founded in 2019 is a community platform where you can find How-to Guides, articles for DevOps Tools,Linux and Databases.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share via
Copy link