Gradle is a free and open source build automation toolset based on the concepts of Apache Ant and Apache Maven. Gradle provides a platform to support the entire development lifecycle of a software project.
In this tutorial, we will install the latest version of Gradle on CentOS 7.
Prerequisites
- A Rcs CentOS 7 server instance.
- A sudo user.
Step 1: System update
Before installing any packages on your CentOS server instance, it is recommended to update the system. Login using the sudo user and run the following commands to update the system.
sudo yum -y install epel-release
sudo yum -y update
sudo shutdown -r nowOnce the system has rebooted, log in again as the sudo user and proceed to the next steps.
Step 2: Install JDK
Gradle requires Java Development Kit (JDK) 7 or higher in order to work. In this tutorial we will be installing JDK 8. Run the following command to install JDK 8 on your server.
sudo yum -y install java-1.8.0-openjdk wget unzipThe above command will also install wget and unzip. Verify the installation.
java -versionYou will see the following output.
openjdk version "1.8.0_121"
OpenJDK Runtime Environment (build 1.8.0_121-b13)
OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode)##Step 3: Download Gradle
Gradle distribution archive comes in two types: "binary-only" and "complete". The "binary-only" archive contains the Gradle software only wheres "complete" archive comes with binary, documentation and source. Run the following command to download Gradle to your system.
wget https://services.gradle.org/distributions/gradle-3.4.1-bin.zipYou can always check the Gradle release page to look for the link to the latest version of Gradle.
##Step 4: Install Gradle
Create a directory for the Gradle installation.
sudo mkdir /opt/gradleExtract the downloaded archive to the newly created directory.
sudo unzip -d /opt/gradle gradle-3.4.1-bin.zipConfigure the PATH environment variable so that the gradle executable can be directly executed anywhere on the system.
export PATH=$PATH:/opt/gradle/gradle-3.4.1/binYou can run the following command to check if the Gradle install was successful.
gradle -vYou should see the following output.
------------------------------------------------------------
Gradle 3.4.1
------------------------------------------------------------
Build time: 2017-03-03 19:45:41 UTC
Revision: 9eb76efdd3d034dc506c719dac2955efb5ff9a93
Groovy: 2.4.7
Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM: 1.8.0_121 (Oracle Corporation 25.121-b13)
OS: Linux 3.10.0-514.10.2.el7.x86_64 amd64The installation is complete. Your system is now ready to build programs using Gradle.