Gradle is a powerful and flexible build tool, mainly used for Java projects, combining the advantages of Ant and Maven. Unlike other preprocessing tools that use XML, Gradle uses Groovy, a dynamic, object-oriented Java platform language for defining projects and build scripts.
This article explains how to install Gradle on CentOS 8. We will download the latest version of Gradle from their official website.
The following instructions assume that you have logged into the system as root or another user with sudo privileges.
Gradle installs Java SE 8 or newer on the server.
Enter the following command to install the OpenJDK package:
sudo yum install java-1.8.0-openjdk-devel
Verify the Java installation by printing the Java version number:
java -version
The output should look like this:
openjdk version "11.0.6"2020-01-14 LTS
OpenJDK Runtime Environment 18.9(build 11.0.6+10-LTS)
OpenJDK 64-Bit Server VM 18.9(build 11.0.6+10-LTS, mixed mode, sharing)
At the time of writing, the latest version of Gradle is 6.3
. Before proceeding to the next step, you should check Gradle Release Page to see if there is a newer version available.
Use the wget
command to download the Gradle binary file to the /tmp
folder:
wget https://services.gradle.org/distributions/gradle-6.3-bin.zip -P /tmp
Once the download is complete, unzip the file to the /opt/gradle
folder:
sudo unzip -d /opt/gradle /tmp/gradle-*.zip
If you get an error message saying`sudo: unzip: command not found`,use`sudo dnf install unzip`Install the unzip package.
Verify that Gradle has been decompressed:
ls /opt/gradle/gradle-*
The output is as follows:
bin init.d lib LICENSE NOTICE README
Next, we will configure the PATH environment variable to include Gradle's bin directory. To do this, open your file editor and create a file named gradle.sh
in the /etc/profile.d
directory:
sudo nano /etc/profile.d/gradle.sh
Copy and paste the following code:
export GRADLE_HOME=/opt/gradle/gradle-6.3export PATH=${GRADLE_HOME}/bin:${PATH}
Save and close the file. The script will be effective the next time the shell is started.
Make the script executable by triggering the following chmod command:
sudo chmod +x /etc/profile.d/gradle.sh
Use the source command to load environment variables:
source /etc/profile.d/gradle.sh
To verify whether Gradle is installed correctly, run the following command, the Gradle version will be displayed:
gradle -v
You can see information similar to the following:
Welcome to Gradle 6.3!
Here are the highlights ofthis release:- Java 14 support
- Improved error messages for unexpected failures
For more details see https://docs.gradle.org/6.3/release-notes.html
------------------------------------------------------------
Gradle 6.3------------------------------------------------------------
Build time:2020-03-2419:52:07 UTC
Revision: bacd40b727b0130eeac8855ae3f9fd9a0b207c60
Kotlin:1.3.70
Groovy:2.5.10
Ant: Apache Ant(TM) version 1.10.7 compiled on September 12019
JVM:11.0.6(Oracle Corporation 11.0.6+10-LTS)
OS: Linux 4.18.0-80.11.2.el8_0.x86_64 amd64
that's it. You have installed the latest Gradle on your CentOS system, and you can start using it.
We have shown you how to install Gradle on CentOS 8.
You can now browse Gradle official documentation page and learn Gradle Quick Start.
Recommended Posts