How to install Gradle on Ubuntu 20.04

Gradle is distributed as a multi-language automation utility for software development. It’s capable of managing and automating the different phases of a software’s project life-cycle: software compiling and packaging to testing, deployment, and releasing updates. Gradle is specialized in performing multi-project builds.

Gradle borrows its fundamental ideas from Apache Ant and Apache Maven and adds to their aspects by boasting the Groovy-based domain-specific language. This is, of course, different from Maven, which uses the XML form used to present the project’s overview. It’s also set apart from other utilities of its kind by its application of acyclic graph, which, through dependency management, it uses to evaluate the optimum sequence of the tasks associated with the project.

This is a short walkthrough to help you install Gradle on Ubuntu 20.04.

Step 1: Installing JDK

We must install OpenJDK 8 or 11 first. Use the command below to proceed:

$ sudo apt update

$ sudo apt install [jdk-version]

Alternatively, you can use the following command to install OpenJDK 11

$ sudo apt install openjdk-11-jdk

Now see what java version you have. I have the latest version 14 installed:

$ java --version

Step 2: Download Gradle

For this demonstration, we’ll be downloading Gradle version 6.4. You can opt to download the latest version or any version of your choice from the Gradle’s official website.

We’ll be downloading Gradle’s installing in the /tmp directory. Type in the following command:

$ cd /tmp

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

Extract the gradle binary setup in the /opt/gradle directory

$ sudo unzip -d /opt/gradle gradle-6.4.1-bin.zip

Alternatively, you can install the default version of the Gradle that is recommended for Ubuntu.

Enter the following codes to append a PPA repository, custom for Gradle:

$ sudo apt -y install vim apt-transport-https dirmngr wget software-properties-common

$ sudo add-apt-repository ppa:cwchien/gradle

$ sudo apt update

$ sudo apt -y install gradle

With the above commands, you’d have Gradle successfully installed on your computer.

Step 3: Configuring the Environment Variable

To configure the environment variable, open the below file:

$ sudo gedit /etc/profile.d/gradle.sh

Now add the following line into the file:

# /etc/profile.d/gradle.sh
# export PATH=$PATH:/opt/gradle/gradle-6.4.1/bin

Then fire up the variables by entering the following commands:

$ source /etc/profile.d/gradle.sh

Step 4: Verifying the installation

You can verify what version you’ve downloaded with following commands:

$ gradle -v

Wrapping up

In this walkthrough, we’ve looked at Gradle, and see how it is installed on Ubuntu 20.04. We also made configurations to the environment variable for Gradle. I hope you’ve found this walkthrough helpful, and that you’ve found it easy to install Gradle on your system.

About the author

Younis Said

Younis Said

I am a freelancing software project developer, a software engineering graduate and a content writer. I love working with Linux and open-source software.