How to Install Gradle on CentOS 7

Install Gradle on CentOS 7

In this article, we will have explained the necessary steps to install and configure Gradle on CentOS 7. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

Gradle is a free and open source build automation toolset based on the concepts of Apache Ant and Apache Maven. Unlike its predecessors which use XML for scripting, Gradle uses Groovy, a dynamic, object-oriented programming language for the Java platform to define the project and build scripts.

Install Gradle on CentOS

Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.

Step 2. Install OpenJDK.

Gradle requires Java to be installed on your system. To install OpenJDK 8 run following command in terminal:

To verify that Java was successfully installed, run the following command:

Step 3. Install Gradle.

First, download Gradle from official Gradle release page. The latest Gradle version available is 5.1:

Now unzip downloaded zip file using following command:

Step 4. Setup environment variables.

Next step is to configure the PATH environment variable to include the Gradle bin directory. To do so, open your text editor and create a new file named gradle.sh inside of the /etc/profile.d/ directory:

Now make script file executable using following command:

Load the environment variables using following command:

Step 5. Verify Installation.

To verify if Gradle is installed properly use the gradle -v command which will display the Gradle version:

Congratulation, you have learned how to install and configure Gradle on CentOS 7. If you have any question, please leave a comment below.