How to install Gradle on CentOS 8

How to install Gradle on CentOS 8

Install Gradle on CentOS

Gradle is a free, open source, general purpose build tool used primarily in Java projects. Define projects and create Java language scripts using Groovy, a dynamic object-oriented programming language. Gradle is also used to build Android projects in Android Studio. In this tutorial, you will learn how to install Gradle on CentOS 8.

Prerequisites

Before installing Gradle on CentOS. Requires a non-root user account on the server / desktop with sudo privileges.

Install OpenJDK

Gradle requires Java to be installed on the system. To install OpenJDK 8, execute the following command in a terminal:

sudo yum install java-1.8.0-openjdk-devel

Confirm the OpenJDK installation by entering the following command:

java -version

Download Gradle

Gradle can be downloaded from: Official Gradle release page. The latest Gradle version available 5.1. If a new version is available, you can check it by visiting the website.

To download Gradle 5.1 using wget Execute the following command:

wget https://services.gradle.org/distributions/gradle-5.1-bin.zip -P /tmp

Unzip the downloaded zip file using the following command:

sudo unzip -d /opt/gradle /tmp/gradle-5.1.zip

Setting up environment variables

Your PATH environment variable must include the Gradle directory. Must be created gradle.sh Internal files /etc/profile.d/ directory. To create the file, run the following command:

sudo nano /etc/profile.d/gradle.sh

Next, paste the following code into the above file.

export GRADLE_HOME=/opt/gradle/gradle-5.1
export PATH=${GRADLE_HOME}/bin:${PATH}

Save the file and close the file.

Make the script file executable with the following command:

sudo chmod +x /etc/profile.d/gradle.sh

Load the environment variables using the following command:

source /etc/profile.d/gradle.sh

Confirm installation

Verify the installation of Gradle using the following command:

gradle -v

The output looks like this:

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 https://docs.gradle.org/5.1/release-notes.html


------------------------------------------------------------
Gradle 5.1
------------------------------------------------------------

Build time:   2019-11-27 11:48:43 UTC
Revision:     e0824aec8a0f5462fc5fd9872664dbc7fc6e5abf

Kotlin DSL:   1.0.4
Kotlin:       1.3.10
Groovy:       2.5.4
Ant:          Apache Ant(TM) version 1.9.13 compiled on January 5 2019
JVM:          1.8.0_181 (Oracle Corporation 25.181-b13)
OS:           Linux 4.15.0-36-generic amd64

Conclusion

I have learned how to install Gradle on CentOS 8. If you have questions about this, don’t forget the comments below.

Sidebar