Categories: LinuxShellUbuntu

How to Install Gradle Build-Tool on Ubuntu 20.04

Gradle is a well-known software build-tool that is mostly used for development in Java, C++, and Swift. By combining all of the best features of Ant and Maven, it brings the best development practices to its users. Instead of using XML language for scripting, Gradle uses Groovy which is an OO language for defining the project.

This article will show you how to install Gradle with a few simple steps on an Ubuntu 20.04 system.

Pre-Requisites

  • Ubuntu 20.04 system preferably
  • User with sudo rights

Installation of OpenJDK

To install Gradle in your computer system, you need to have Java installed on your machine. To do so, open up the terminal window on your machine using the Ctl+Alt+T shortcut. Or you can simply go to the Applications of your system. Then type Terminal keyword in the search bar of your Applications window.

Once you have opened up the terminal window, enter these commands to install OpenJDK.

$ sudo apt update

The updates will begin like this:

Once the apt package is updated, enter the following command to install OpenJDK.

$ sudo apt install openjdk-11-jdk

The system will prompt, type Y to continue the installation process.

The next step is to confirm the installation of Java. To do so, let’s check the installed Java version.

$ java -version

You will see the java version in the output.

Download Gradle in Ubuntu 20.04

To know about the available releases, simply visit the Gradle release page. To this date, the latest Gradle version is 6.8.2. This may vary at the time of your download.

$ VERSION=6.8.2

Next, we will download Gradle zip file (Binary only) in the /tmp directory. We will use the following wget command:

$ wget https://services.gradle.org/distributions/gradle-${VERSION}-bin.zip -P /tmp

After this, the download will begin. You will see an output just this one:

Once the download of Gradle is completed, users need to unzip the file. This newly created unzipped file will be added to the /opt/gradle directory:

$ sudo unzip -d /opt/gradle /tmp/gradle-${VERSION}-bin.zip

This way the process of downloading Gradle will be completed.

Setting up the Environment variables for the new Gradle setup

Let’s set up the environment variables for the newly installed Gradle setup by adding Gradle bin directory to PATH environment variables. We will create a new file and then name it gradle.sh and place it in the /etc/profile.d/ directory. To do so, open up the file in nano editor by using:

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

Once the editor window is opened, you need to type the following in the /etc/profile.d/gradle.sh file.

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

Use, the Ctl+O shortcut to make changes in the file.

Let’s make the script executable using:

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

To load the environment variables in your shell session use:

$ source etc/profile.d/gradle.sh

Verifying the installation

Once you have installed Gradle in your system, let’s verify this installation by checking the Gradle version. Append the following your terminal window to confirm the installation process.

$ gradle -v

Your output will look like this:

This marks an end to the installation of Gradle in your system.

Conclusion

In this tutorial, we wrapped up the installation method of Gradle on the Ubuntu 20.04 system in detail. To install Gradle, users need to have OpenJDK installed in their systems and then they have to set up the environment variables to make use of this tool. To know more about Gradle, visit their official documentation.

 

Karim Buzdar

About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. You can reach Karim on LinkedIn

Recent Posts

How to Install Magento 2 on AlmaLinux

Magento is a free and open-source e-commerce platform written in PHP. It is simple, easy…

1 year ago

How to Install ISPConfig Hosting Control Panel with Apache Web Server on Ubuntu 24.04

ISPConfig is an open-source control panel that allows users to manage multiple servers from a…

1 year ago

How to Test your Email Server (SMTP) Using the Telnet Command

As a Linux administrator, you may find it necessary to troubleshoot or test your Simple…

1 year ago

Managing Network Interfaces and Settings on Ubuntu 24.04 with nmcli

Ubuntu 24.04, like many modern Linux distributions, relies on the NetworkManager for managing network connections.…

2 years ago

Using Restic Backup on Ubuntu 24.04

Restic is a modern, open-source backup program designed for efficiency, security, and simplicity. It enables…

2 years ago

Installing phpMyAdmin on Rocky Linux 9 and Securing it with Let’s Encrypt SSL

phpMyAdmin is a popular free tool written in PHP intended to administer MySQL and MariaDB…

2 years ago