How to install Gradle on Debian 10?

Overview

Gradle is a build automation tool that is used to create a variety of applications, including microservices and mobile apps. Applications may be built, tested, and maintained using the Gradle framework. Furthermore, if you are working on a multi-build project, Gradle continuously checks your work to see whether you have made any changes.

This tutorial explains you how to setup Gradle on Debian 10.

Prerequisites

There are certain prerequisites that need to be met before you begin.

  • A machine running Debian 10

  • A root user having Sudo privileges

  • Internet connection

Get Started

Step 1. Installing OpenJDK

  • Always be sure to update your system before downloading the latest packages. Run the following command to do it:

sudo apt update
  • Since Java is a prerequisite for Gradle, we will first install the most recent version of Java that is accessible in the default repository. Type the following command to set up the OpenJDK package:

sudo apt install default-jdk
  • Run the below command to check the Java version installed:

java -version

Step 2. Downloading Gradle

You should go through the Gradle releases page to determine whether a newer version is accessible.

  • Use the wget command to get the Gradle binary file:

wget https://services.gradle.org/distributions/gradle-6.3-bin.zip -P /tmp
  • Unzip the zip file in the /opt/gradle directory when the download is completed.

sudo unzip -d /opt/gradle /tmp/gradle-*.zip
  • Make sure the Gradle files have been extracted by checking with the following command:

ls /opt/gradle/gradle-*

Step 3. Environment Variables Configuration

  • The Gradle bin directory must be included in the PATH environment variable, which needs to be configured next. To achieve this, launch your text editor and make a new file called gradle.sh inside the /etc/profile.d directory.

sudo nano /etc/profile.d/gradle.sh
  • Paste the following lines as shown below in the /etc/profile.d/gradle.sh:

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

Save and exit the file. This script will be loaded when the shell launches.

  • Run the chmod command to modify the file's access mode, allowing it to be read-only or write-only:

sudo chmod +x /etc/profile.d/gradle.sh
  • The environment variables that we specified for Gradle in the present environment must be initialised. Run the following command to do so:

source /etc/profile.d/gradle.sh

Step 4. Checking Gradle Installation

  • Run the command below, which will show the Gradle version, to make sure Gradle is installed correctly:

gradle -v

Gradle has been successfully installed on your Debian 10 system, and you can now use it.

Conclusion

In this tutorial, we have successfully mastered the steps required to install Gradle on Debian 10 as well as all the necessary commands.

Last updated