Introduction
Gradle is an open-source build automation tool that is used mostly in Java projects. It automates the building process of applications which includes compiling, linking, and packaging of code without manual input.Gradle also supports Groovy, which is an object-oriented dynamic language created for Java applications.
Install OpenJDK on CentOS 8
We need to install OpenJDK first to ensure that it runs smoothly without a problem. We are going to install OpenJDK 11 which offers Long Term Support execute:
# yum install java-11-openjdk
![](http://unixcop.com/wp-content/uploads/2021/07/1-1-1-1024x447.png)
Verify the installation of OpenJDK :
# java -version
![](http://unixcop.com/wp-content/uploads/2021/07/2-1-1.png)
The output clearly shows that we have installed OpenJDK version 11.0.11.
Download Gradle
So the next step is to download Gradle. As I am penning this article, Gradle 7.1.1 is the latest version. Feel free to glance at the Gradle releases page for newer versions.
For now, let’s download the current Gradle zip file as shown.
# wget https://services.gradle.org/distributions/gradle-7.1.1-bin.zip
![](http://unixcop.com/wp-content/uploads/2021/07/3-1-1-1024x276.png)
Then move the zip file to the /opt directory as shown.
# mv gradle-7.1.1-bin.zip /opt
In addition to go to /opt directory and Unzip the contents of the Gradle zip file as follows.
# cd /opt
# unzip gradle-7.1.1-bin.zip
![](http://unixcop.com/wp-content/uploads/2021/07/4-1-1.png)
So Unzipping yields a Gradle folder labeled gradle-7.1.1.To confirm that all the Gradle files are in place, run the command:
# ls gradle-7.1.1
![](http://unixcop.com/wp-content/uploads/2021/07/5-1-1.png)
Configure the environment variables
We need to set the PATH variable to the Gradle bin directory. So we will create a gradle.sh script file as shown in the directory /etc/profile.d
# vim /etc/profile.d/gradle.sh
Define the path variable as shown
export GRADLE_HOME=/opt/gradle-7.1.1
export PATH=${GRADLE_HOME}/bin:${PATH}
![](http://unixcop.com/wp-content/uploads/2021/07/6-1-1.png)
Save and exit the Gradle script file. Proceed and assign execute permissions to the Gradle script as shown.
# chmod +x /etc/profile.d/gradle.sh
To apply the changes and notify the shell, use the source command.
# source /etc/profile.d/gradle.sh
Confirm installation of Gradle
The only thing we are left to do is to verify if the installation of Gradle was successful. To achieve this, execute the command:
# gradle -v
![](http://unixcop.com/wp-content/uploads/2021/07/7-1-1.png)
The output provides a decent amount of information including the version of Gradle, highlights about the latest release, build time, and versions of Kotlin and Groovy.
Conclusion
We have managed to successfully install the latest version of Gradle on CentOS 8.