How to install Gradle on CentOS 8

How To Install Gradle On Linux CentOS 8

On this article we will discuss how to install Gradle 6.8 on CentOS 8.

Introduction

Gradle is a open-source build tool automation system used primarily for Java projects. It combines the best features of Apache Ant and Apache Maven. Gradle uses a Groovy-based domain-specific language instead of the XML form used by Maven for declaring the project configuration. Gradle supports incremental builds and designed for multi-project builds. Gradle initial relealsed on 2007 or about 14 years ago, and the last stable release on January 8, 2021 with Gradle version 6.8.

On this article we will discuss how to install Gradle on Linux CentOS 8 operating system. Whe will use Gradle version 6.8 as our source for this tutorial. The Gradle installation will be consist of several steps as described below.

  • Prerequisite
  • Download and Extract Gradle package
  • Setup Environment Variable
  • Verify the Gradle installation

Prerequisite

Gradle installation needs several prerequisites, then we have to check its requirement first. We need sufficient space for Gradle binnary files and also root account or and account with sudo privilege. Gradle requires Java JDK or JRE version 7 or above to be installed on the system.

Before continuing to the next step, just ensure our Java installed on the system. And if we have no Java installed yet, just install it. Java installation on CentOS article can be found on : How To Install Java (OpenJDK 11) On CentOS 8.

[ramans@otodiginet ~]$ java -version 
openjdk version "11.0.9.1" 2020-11-04 LTS 
OpenJDK Runtime Environment 18.9 (build 11.0.9.1+1-LTS) 
OpenJDK 64-Bit Server VM 18.9 (build 11.0.9.1+1-LTS, mixed mode, sharing)
java version on centos 8
OpenJDK

Download and Extract Gradle Package

After all prerequisite are met, then we will download and extract Gradle package file from the official source. On this article we will be using Gradle version 6.8. and /home/ramans directory as a destination. We will submit the command line : wget https://services.gradle.org/distributions/gradle-6.8-all.zip.

[ramans@otodiginet ~]$ wget https://services.gradle.org/distributions/gradle-6.8-all.zip
 --2021-01-21 16:38:08--  https://services.gradle.org/distributions/gradle-6.8-all.zip
 Resolving services.gradle.org (services.gradle.org)… 104.18.190.9, 104.18.191.9, 2606:4700::6812:bf09, …
 Connecting to services.gradle.org (services.gradle.org)|104.18.190.9|:443… connected.
 HTTP request sent, awaiting response… 301 Moved Permanently
 Location: https://downloads.gradle-dn.com/distributions/gradle-6.8-all.zip [following]
 --2021-01-21 16:38:08--  https://downloads.gradle-dn.com/distributions/gradle-6.8-all.zip
 Resolving downloads.gradle-dn.com (downloads.gradle-dn.com)… 104.17.159.20, 104.17.160.20, 2606:4700::6811:a014, …
 Connecting to downloads.gradle-dn.com (downloads.gradle-dn.com)|104.17.159.20|:443… connected.
 HTTP request sent, awaiting response… 200 OK
 Length: 150596628 (144M) [application/zip]
 Saving to: ‘gradle-6.8-all.zip’
 gradle-6.8-all.zip          100%[==========================================>] 143.62M  1.02MB/s    in 6m 8s   
 2021-01-21 16:44:17 (400 KB/s) - ‘gradle-6.8-all.zip’ saved [150596628/150596628]
Download Gradle 6.8 package
Download Gradle 6.8 package

Then we will extract it to the /opt/gradle directory.

[ramans@otodiginet ~]$ sudo unzip -d /opt/gradle gradle-6.8-all.zip
Extract Gradle 6.8 package
Extract Gradle 6.8 Package

Setup Environment Variable

After Gradle package were extracted then we will setup the environment variable of Gradle 6.8. This task could be done by creating a file /etc/profile.d/gradle.sh with the following entries :

 [ramans@otodiginet ~]$ sudo vi /etc/profile.d/gradle.sh

 export GRADLE_HOME=/opt/gradle/gradle-6.8
 export PATH=${GRADLE_HOME}/bin:${PATH}
Gradle 6.8 Environment variable
Gradle 6.8 Environment variable

Then we make the file maven.sh by submitting commane line :

 [root@otodiginet ~]# chmod +x /etc/profile.d/gradle.sh
 [root@otodiginet ~]# source /etc/profile.d/gradle.sh
Make Gradle file
Make Gradle file

Verify the Gradle installation

After all installation processes were done, then we will verfity the Gradle 6.8 installation by querying its version. This task will use the command line : gradle -v as shown below :

[root@otodiginet ~]# gradle -v
 Welcome to Gradle 6.8!
 Here are the highlights of this release:
 Faster Kotlin DSL script compilation
 Vendor selection for Java toolchains
 Convenient execution of tasks in composite builds
 Consistent dependency resolution 
 For more details see https://docs.gradle.org/6.8/release-notes.html
 
 Gradle 6.8
 Build time:   2021-01-08 16:38:46 UTC
 Revision:     b7e82460c5373e194fb478a998c4fcfe7da53a7e
 Kotlin:       1.4.20
 Groovy:       2.5.12
 Ant:          Apache Ant(TM) version 1.10.9 compiled on September 27 2020
 JVM:          11.0.9.1 (Red Hat, Inc. 11.0.9.1+1-LTS)
 OS:           Linux 4.18.0-193.el8.x86_64 amd64 
Gradle version 6.8
Gradle version 6.8

Conclusion

On this article we have tried to install Gradle 6.8 on Linux CentOS 8 operating system. The installation was quite done successfully. For more resource about Gradle 6.8 can be found on Gradle official web site.

Share this article via :

Leave a Reply

Your email address will not be published. Required fields are marked *