How to install Gradle on Debian 10

How to install Gradle on Debian 10

Install Gradle on Debian

Gradle is a free, open source, general purpose build tool used primarily in Java projects. Use Groovy, a dynamic object-oriented programming language, to define projects and script Java language. Gradle is also used to build Android projects in Android Studio. In this tutorial, you will learn how to install Gradle on Debian 10.

Prerequisites

Before you start installing Gradle on Debian 10, you need a non-root user account with sudo privileges on the server / desktop.

Install OpenJDK

First update apt Enter the following command to enter the Debian package manager index:

sudo apt update

Gradle requires Java to be installed on the system. To install OpenJDK 8, execute the following command in a terminal:

sudo apt install openjdk-8-jdk

Confirm the OpenJDK installation by entering the following command:

java -version

Download Gradle

Gradle can be downloaded from the official Gradle release page. The latest Gradle version available 5.1. If a new version is available, you can visit their website and check.

To download Gradle 5.1 using wget Execute the following command:

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

Unzip the downloaded zip file using the following command:

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

Setting up environment variables

Your PATH environment variable must include the Gradle directory. Must be created gradle.sh Internal files /etc/profile.d/ directory. To create the file, run the following command:

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

Next, paste the following code into the above file.

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

Save the file and close the file.

Make the script file executable with the following command:

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

Load the environment variables using the following command:

source /etc/profile.d/gradle.sh

Confirm installation

Verify the installation of Gradle using the following command:

gradle -v

The output looks like this:

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:   2018-12-29 11:48:43 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

Conclusion

You have learned how to install Gradle on Debian 10. If you have any questions about this, don’t forget to comment below.

Sidebar