Gradle is a general-purpose build tool used primarily for Java projects. It combines the best features of Ant and Maven. Gradle uses Groovy instead of using XML for scripting.
In this tutorial we will show you how to install the latest version of Gradle on CentOS 7 / RHEL 7.
Prerequisites
You’ll need to be logged in as a user with sudo
privileges in order to install Gradle
1. Install OpenJDK
– Gradle requires Java JDK or JRE version 7 or above to be installed. Use the below command to install OpenJDK 8.
# yum install java-1.8.0-openjdk
– To verify that Java was successfully installed, run the following command:
# java -version openjdk version "1.8.0_161" OpenJDK Runtime Environment (build 1.8.0_161-b14) OpenJDK 64-Bit Server VM (build 25.161-b14, mixed mode)
2. Download Gradle
– To download the latest version of Gradle, visit the Gradle releases page. Use the wget
command to download Gradle zip file in the /tmp
directory:
# wget https://services.gradle.org/distributions/gradle-6.4.1-bin.zip -P /tmp
– Once the download is completed, extract the zip file in the /opt/gradle
directory:
# sudo unzip -d /opt/gradle /tmp/gradle-*.zip
3. Setup environment variables
– We’ll need to setup the Gradle environment variables. Open your text editor and create a new file named gradle.sh
inside of the /etc/profile.d/
directory.
# sudo vi /etc/profile.d/gradle.sh export GRADLE_HOME=/opt/gradle/gradle-6.4.1 export PATH=${GRADLE_HOME}/bin:${PATH}
– Finally, load the new environment variables by typing:
# sudo source /etc/profile.d/gradle.sh
4. Verify the Gradle installation
– To verify if Gradle is installed properly use the gradle -v command which will display the Gradle version:
# gradle -v Welcome to Gradle 6.4.1! Here are the highlights of this release: - Define sets of dependencies that work together with Java Platform plugin - New C++ plugins with dependency management built-in - New C++ project types for gradle init - Service injection into plugins and project extensions For more details see https://docs.gradle.org/6.4.1/release-notes.html ------------------------------------------------------------ Gradle 6.4.1 ------------------------------------------------------------ Build time: 2019-02-08 19:00:10 UTC Revision: f02764e074c32ee8851a4e1877dd1fea8ffb7183 Kotlin DSL: 1.1.3 Kotlin: 1.3.20 Groovy: 2.5.4 Ant: Apache Ant(TM) version 1.9.13 compiled on July 10 2018 JVM: 1.8.0_191 (Oracle Corporation 25.191-b12) OS: Linux 3.10.0-957.5.1.el7.x86_64 amd64
Conclusion
You have successfully installed Gradle on your CentOS 7 / RHEL 7. You might want to check the following guides:
We hope this tutorial was enough Helpful. If you need more information, or have any questions, just comment below and we will be glad to assist you!