How to Install Gradle on Debian 10

Install Gradle on Debian 10

In this article, we will have explained the necessary steps to install Gradle on Debian 10. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

Gradle is a free and open source build automation toolset based on the concepts of Apache Ant and Apache Maven. Unlike its predecessors which use XML for scripting, Gradle uses Groovy, a dynamic, object-oriented programming language for the Java platform to define the project and build scripts.

Install Gradle on Debian

Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.

sudo apt update
sudo apt upgrade

Step 2. Install OpenJDK.

Gradle requires Java to be installed on your system. To install OpenJDK 8 run following command:

sudo apt install openjdk-8-jdk

Run the following command to verify that Java was successfully installed:

java -version

Step 3. Install Gradle on Debian.

First, download Gradle from official Gradle release page. The latest Gradle version available is 6.5:

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

Next, unzip a downloaded zip file using the following command:

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

Step 4. Setup environment variables.

Next step is to configure the PATH environment variable to include the Gradle bin directory. To do so, open your text editor and create a new file named gradle.sh inside of the /etc/profile.d/ directory:

sudo nano /etc/profile.d/gradle.sh
export GRADLE_HOME=/opt/gradle/gradle-5.1
export PATH=${GRADLE_HOME}/bin:${PATH}

Now make script file executable using following command:

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

Load the environment variables using following command:

source /etc/profile.d/gradle.sh

Step 5. Verify Installation.

Now verify the installation of Gradle using the following command:

$ gradle -v


Welcome to Gradle 5.1!

Here are the highlights of this release:
 - Kotlin DSL 1.0
 - Task timeouts
 - Dependency alignment aka BOM support
 - Interactive `gradle init`

For more details see https://docs.gradle.org/5.1/release-notes.html


------------------------------------------------------------
Gradle 5.1
------------------------------------------------------------

Build time:   2019-11-29 11:33:23 UTC
Revision:     e0824aec8a0f5462fc5fd9872664dbc7fc6e5abf

Kotlin DSL:   1.0.4
Kotlin:       1.3.10
Groovy:       2.5.4
Ant:          Apache Ant(TM) version 1.9.13 compiled on January 5 2019
JVM:          1.8.0_181 (Oracle Corporation 25.181-b13)
OS:           Linux 4.15.0-36-generic amd64

Congratulation, you have learned how to install and configure Gradle on Debian 10 Buster. If you have any question, please leave a comment below.