HomeTutorialsHow To Install and Configure Gradle on Linux Distributions

How To Install and Configure Gradle on Linux Distributions

Gradle is one of the best open-source automation build tools that are available for Linux systems. The Gradle build tool is used for faster, efficient, and organized software development and production. Gradle can compile source code, convert packages into binary code, make library functions, run the autotest, and many more to automate the software production. If you’re a programmer or involved in the software industry, the Gradle automation tool can be a handy application to automate your works.

Gradle on Linux Distributions


Gradle is written in Java, Kotlin, and Groovy programming language and build under the Apache License. It supports Android Studio, NetBeans, Visual Studio Code, and other software production tools. In this post, we will see how to install and get started with Gradle on Linux.

1. Install Gradle on Ubuntu/Debian


The Gradle tool is available on its website. To install Gradle on Ubuntu/Debian, we will use the get command to store it inside the filesystem; later, we will execute the file on our Linux environment. The following steps will guide you on installing Gradle on Debian-based distributions.

Step 1: Install Java on Ubuntu


Installing Gradle on Linux requires the Java 8 or higher version. In most Ubuntu systems, Java doesn’t come pre-installed. You can run the following commands on your terminal shell with root access to install Java. Here, I’m installing Java 8 on my system.

sudo apt update
sudo apt install openjdk-8-jdk

install Java 8 on Ubuntu Linux

When the installing finishes, you may check the Java version to ensure that it has been installed successfully.

java -version

Step 2: Download Gradle on Ubuntu


Gradle is available as a binary file for Linux systems. You can download it from Gradle’s official website, or you can use the following wget command to download. The following command will save and store the Gradle binary, compressed file inside the tmp directory of your Ubuntu system.

wget https://services.gradle.org/distributions/gradle-5.0-bin.zip -P /tmp

download Gradle on Ubuntu Linux

When the download finishes, you may use the unzip command given below to extract the Gradle binary file.

sudo unzip -d /opt/gradle /tmp/gradle-*.zip

After unzipping, run the following ls command to verify that the Gradle files are successfully stored inside the software installation add-on directory.

ls /opt/gradle/gradle-5.0

ls opt gradle

Step 3: Configure and Set Up Gradle on Ubuntu


After downloading and extracting the Gradle files, we will now edit the configuration script to add the installation path inside the script. On Linux, to edit Gradle’s configuration script, you can run the following nano command on your terminal shell.

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

When the script opens, add the following lines inside the script, then save and exit the file.

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

gradle config

Then, run the following chmod command to make the Gradle script executable on your Ubuntu system.

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

Then load the Gradle environment on your Ubuntu system.

source /etc/profile.d/gradle.sh

load env and check gradle version on Ubuntu

Step 4: Verify Gradle on Ubuntu Linux


Till now, we have seen the method of how you can install Gradle on a Ubuntu/Debian distribution. To verify Gradle on your Ubuntu system, you can simply run a version check command on the terminal. In return, you will get detailed pieces of information about Gradle on your system.

gradle -v

2. Install Gradle on Arch Linux


Gradle is available on the AUR repository and installed on an Arch distribution through the Snap store. You can run the following commands on your Arch terminal shell to get the Arch Linux repository on your system.

git clone https://aur.archlinux.org/snapd.git
cd snapd
makepkg -si

Now, enable the Snap socket and create a symbolic link for Snap on your Arch Linux.

sudo systemctl enable --now snapd.socket
sudo ln -s /var/lib/snapd/snap /snap

Finally, run the following Snap command to install Gradle on your Arch system.

sudo snap install gradle --classic

If you have issues installing Gradle on Arch Linux via Snap, you can download the compiled ZST package from here. When the download finishes, install it through the default package manager.

download ZST

3. Install Gradle on Fedora Linux


The installation method of Gradle on Ubuntu and Fedora is pretty the same. The following method will be executable on all DNF-based Fedora 32/31/30/30 systems. As having Java is a prerequisite for Gradle, we will start by installing Java on our machine.

Step 1: Install Java On Fedora


If you have a Fedora workstation, first run the following command to get the Java 8 or higher on your system. Ensure you have root access on your machine.

sudo dnf install java-1.8.0-openjdk

install java on Fedora Linux

When Java installation finishes, run a version check command to assure that Java is running on your system.

java -version

Step 2: Download And Install Gradle on Fedora Linux


Now, as we will download the compressed zip binary file of Gradle, we will need a zip-unzip tool to extract it. You might want to install a zip-unzip tool on your Fedora Linux if you don’t have any.

sudo dnf install unzip wget

Now, run the following wget command on your terminal shell to download the Gradle binary file. When the download finishes, extract it using the unzip command given below.

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

download build file on fedora

Then run the move command to move the Gradle files inside the /usr/local/gradle directory on your Fedora filesystem.

mv gradle-6.3 /usr/local/gradle

Step 3: Configure and Run Gradle on Fedora


In this stage, we will set up the Gradle environment on our Fedora system. You can run the following command to edit the Gradle configuration script.

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

When the script opens, add the following path line inside the script, then save and exit the file.

export PATH=/usr/local/gradle/bin:$PATH

configure gradle on fedora

Finally, run the source command to load the Gradle settings on your system.

source /etc/profile.d/gradle.sh

At the ending, you might want to be sure that Gradle works successfully on your system. You may run the version check to ensure that you have Gradle on your system.

gradle -v

build automation tool check on fedora

Final Words


Since Gradle is used for automation, you can use Gradle with Jenkins if you have an existing Jenkins server on your system. From here, you can get the Gradle-Jenkins plugin for your Ubuntu system. In the entire post, I’ve demonstrated the method of installing the Gradle tool on a Ubuntu machine. Please share this post if you find it helpful and handy. You can also write down your opinions in the comment section below.

Mehedi Hasan
Mehedi Hasan
Mehedi Hasan is a passionate enthusiast for technology. He admires all things tech and loves to help others understand the fundamentals of Linux, servers, networking, and computer security in an understandable way without overwhelming beginners. His articles are carefully crafted with this goal in mind - making complex topics more accessible.
  1. DO NOT install gradle on ARCH in that manor. Snap store is bloatware
    On Arch you must use AUR so:
    pacman -S gradle
    DO NOT USE SNAP STORE!

LEAVE A REPLY

Please enter your comment!
Please enter your name here


You May Like It!

Trending Now