How to Install Gradle on Debian 11

Choose a different version or distribution

Introduction

Before we begin talking about how to install Gradle on Debian 11, let's briefly understand – What is Gradle?

Gradle is a tool that is used in the development of various applications. It offers management of necessary libraries, application deployment, testing, publication, and notifications across many platforms in addition to development assistance.

Similar to the apache maven and ant, but in a more advanced version, Gradle employs Groovy, a DSL (Domain Specific Language), to write its script. This speeds up Gradle's performance compared to the apache maven, which uses XML. The Gradle is supported in Java, Javascript, and C/C++.

Let's use Java as an example. Gradle makes it simple to create custom plugins by allowing you to stack prebuilt functionality on top of your own ideas. It is a well-liked tool since it is adaptable and simple to use, even for complicated applications.

In this tutorial, you will install Gradle on Debian 11. We will also address a few FAQs on how to install Gradle on Debian 11.

Advantages of Gradle

  1. Dependency management: Gradle simplifies managing dependencies, making it easy to include and update libraries in your projects.
  2. Build automation: Gradle automates the build process, enabling efficient and customizable compilation, testing, and packaging workflows.
  3. Flexibility: Gradle supports various project structures, languages, and integrations, allowing developers to create versatile and efficient build scripts.
  4. Incremental builds: Gradle tracks changes at the task-level, allowing for faster builds by only executing necessary tasks.
  5. Rich ecosystem: Gradle has a large community and

Steps to Install Gradle on Debian 11 Bullseye

You only need to enter a few basic commands at the Debian 11 terminal to install Gradle. The commands can be executed either as root or with root privileges by using the sudo keyword.

Step 1: Update the repository

Before running Debian 11, it is advised to update the repository once so that it can download the most recent packages. Execute the subsequent command to update:

sudo apt update

All the packages have been verified as being up-to-date.

Step 2: Installation of Java

We will run the following command to install Java because Gradle needs it as a requirement.

sudo apt install default-jdk

Check the Java version with the following command when the installation is complete to ensure that Java was installed correctly:

java -version

The output displays Java version information, which is a sign that the installation of Java was successful.

Step 3: Downloading of Gradle

The most recent version of Gradle, version 6.9.1, was released on August 20, 2021. For more information, go to the official Gradle website. Using the wget command, we can get Gradle binary files in Zip format.

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

It will take some time to download; once it has, use the unzip command to extract the zip file in the /opt/gradle/ directory:

sudo unzip -d /opt/gradle /tmp/gradle-6.9.1-bin.zip
💡
If got an error like unzip: command not found fix it by installing the unzip package sudo apt install unzip.

Use the ls command to list all the paths in the directory /opt/gradle to confirm the file has been unzipped.

ls /opt/gradle

The folder name is coloured blue to indicate that it has been unzipped, and the .zip file extension has disappeared as a result of the file's unzipping.

Step 4: To set up environment variables

After the Gradle installation file has been successfully unzipped, we will use environment variables to set the PATH so that it contains the Gradle bin directory. To accomplish this, we will create and open a file called "Gradle.sh" in the /etc/profile.d directory using the nano text editor.

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

The text below will now be added for Gradle configuration.

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

To save a file, press CTRL+S, and then CTRL+X to exit.

Step 5: Modify the access permissions of the file

Using the chmod command, we must modify the file's permissions after configuring the Gradle file in order for it to be executable:

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

The access permissions have been modified.

Step 6: Installation of Gradle file

After modifying the permissions for access, we will use the source command to load the environment variables and install the Gradle file.

source /etc/profile.d/gradle.sh

The fact that the environment variables have been loaded indicates that Gradle 6.9.1 has been set up on Debian 11.

Step 7: Verification of the installation

When the installation is finished, we'll check the version to make sure everything went as planned.

gradle -version

The output shows the Gradle's version information as well as some of the highlights of its most recent version.

FAQs to Install Gradle on Debian 11

How can I check if Gradle is installed correctly?

Run gradle --version in the terminal. It should display the installed Gradle version.

What are the system requirements for installing Gradle? 

Gradle requires a Java Development Kit (JDK) to be installed. Make sure you have JDK installed before proceeding.

How do I set up the environment variables for Gradle? 

Edit the .profile or .bashrc file and add the following line: export PATH=$PATH:/usr/share/gradle/bin. Then, save the file and reload it using source ~/.profile or source ~/.bashrc.

Can I install Gradle globally for all users? 

Yes, you can install Gradle system-wide by using sudo apt install gradle.

How do I update Gradle to the latest version? 

You can update Gradle by running sudo apt upgrade gradle. This will upgrade Gradle to the latest version available in the Debian repositories.

Can I install specific Gradle versions on Debian 11?

Yes, Debian 11 typically offers the latest stable version of Gradle available. However, you can install specific versions by downloading the desired version from the Gradle website and manually installing it.

Can I use a different package manager to install Gradle on Debian 11?

While apt is the recommended package manager for Debian, you can use alternatives like SDKMAN! or manual installation by downloading from the Gradle website.

Conclusion

Gradle is the application development tool. It was introduced in 2007 and is faster, more powerful, and more flexible than Ant and Maven. In comparison to earlier tools for building, such as Apache Ant, Apache Maven, Grunt, and Gulp, Gradle is a vastly better tool. This tutorial covered how to install Gradle on Debian 11 by downloading the zip file from the Gradle website and installing Java. Make the configuration file for the zip file when it has been downloaded, load it to install Gradle 6.9.1, and then verify the installation by comparing it to the version at the end.

If you have any queries, please leave a comment below, and we’ll be happy to respond to them.