How to Install and Configure Gradle on Ubuntu 20.04

how to install gradle on ubuntu 20.04

Grade is a build tool used for automate development processes. Gradle automation includes testing, compiling, deploying publish process. Its speed up the software development process and gives the best software. Gradle is mainly used to build  C++, Java software. It’s an Apache ant and Maven features mixed tool.

In this article we are going to learn how to install and config Gradle on Ubuntu 20.04. Let begin the installation.

Install Java:

Gradle needs Java so we have to install Java first. We need a Java 8 is the minimum requirement to run Gradle. To install OpenJDK 11 run the commands below.

sudo apt update
sudo apt install openjdk-11-jdk

After the installation now check the version of Java.

java -version
Output

openjdk version "11.0.8" 2020-07-14
OpenJDK Runtime Environment (build 11.0.8+10-post-Debian-1deb10u1)
OpenJDK 64-Bit Server VM (build 11.0.8+10-post-Debian-1deb10u1, mixed mode, sharing)

Install Gradle:

To install the Gradle on Ubuntu 20.04 go to Gradle release webpage and check for latest version then download. To download the latest version of Gradle run the command below.

wget https://downloads.gradle-dn.com/distributions/gradle-6.6.1-bin.zip

After successful download unzip the Gradle binary file.

We need unzip package installed on ubuntu 20.04 to unzip the file. To install unzip package on Ubuntu 20.04 run the command below.

sudo apt install unzip

After installing unzip package on Ubuntu 20.04 unzip the file now.

unzip gradle-6.6.1-bin.zip
sudo mv gradle 6.6.1 /opt/gradle

Now Gradle configuration is successfully finished.

Config Environment Variables:

We have to include the Gradle bin directory to the path environment variable. Now we have to create a gradle.sh file in the /etc/profile.d directory.

sudo nano /etc/profile.d/gradle.sh

After opening gradle.sh copy and paste the below configuration content.

export GRADLE_HOME=/opt/gradle/gradle-6.6.1
export PATH=${GRADLE_HOME}/bin:${PATH}

After that save and close the gradle.sh file.

To make the script executable run the command below.

sudo chmod +x /etc/profile.d/gradle.sh

After that source the gradle.sh file to apply configuration in the current session.

source /etc/profile.d/gradle.sh

Environment variables configuration is completed. Next move to the Gradle verification.

Gradle Verification:

To check if Gradle is installed or not run the command below.

gradle -v
Output

------------------------------------------------------------
Gradle 6.5.1
------------------------------------------------------------

Build time:   2020-06-30 06:32:47 UTC
Revision:     66bc713f7169626a7f0134bf452abde51550ea0a

Kotlin:       1.3.72
Groovy:       2.5.11
Ant:          Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM:          11.0.8 (Debian 11.0.8+10-post-Debian-1deb10u1)
OS:           Linux 4.19.112+ amd64

That’s all we have successfully installed Gradle on Ubuntu 20.04.

Conclusion:

Successfully we have installed Gradle on Ubuntu 20.04. In this article we have learned how to install and config Gradle on Ubuntu 20.04.

Next Article: How to Install and Setup Jenkins on Ubuntu 20.04

Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like