Install Gradle on Debian 10/9

0
1916

In this guide, we are going to learn how to install Gradle on Debian 10/9. Gradle is an open-source build automation tool for building (but not limited) Java-based projects. Gradle build scripts are written using a Groovy or Kotlin domain-specific language (DSL) instead of the XML form commonly used by Apache Maven for declaring the project configuration.

Install Gradle on Debian 10/9

There are two ways in which Gradle can be installed; Automatically via the package manager and manually using Gradle binary. This guide discusses both ways.

Prerequisites

Gradle runs on the JVM and thus as a prerequisite, you have to install OpenJDK or JRE 8 or later. Hence, update you system and install JDK.

Run system update

apt update
apt upgrade

Install Java on Debian 10/9

We have covered the installation of various versions of Java in our previous guides. See the links below.

Install Oracle Java 12 on Debian 10

How to Manually Install Oracle Java 12 on Debian 10/9/Ubuntu 18.04

Install Oracle Java 12 on Ubuntu 18.04/Debian 10/9

Install Java 11 on Debian 10/9/Ubuntu 18.04

Install Gradle on Debian 10/9 via Package Manager

To install Gradle via package manager, you need to first install SDKMAN!, a tool for managing parallel versions of multiple Software Development Kits on most Unix-like systems.

Install SDKMAN! on Debian 10/9

To install SDKMAN!, run the commands below;

apt install zip curl
curl -s "https://get.sdkman.io" | bash

SDKMAN! is installed on your home directory. Hence, once the installation is done, run the command below source the SDKMAN! init script.

source "$HOME/.sdkman/bin/sdkman-init.sh"

To verify SDKMAN! installation;

sdk version
...
SDKMAN 5.7.3+337

You can now install Gradle using SDKMAN! by running the command;

sdk install gradle

Once the installation of Gradle completes, the installed version is displayed. You can as well check the version as shown below;

gradle -v

Welcome to Gradle 5.4.1!

Here are the highlights of this release:
 - Run builds with JDK12
 - New API for Incremental Tasks
 - Updates to native projects, including Swift 5 support

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

------------------------------------------------------------
Gradle 5.4.1
------------------------------------------------------------

Build time:   2019-04-26 08:14:42 UTC
Revision:     261d171646b36a6a28d5a19a69676cd098a4c19d

Kotlin:       1.3.21
Groovy:       2.5.4
Ant:          Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM:          12.0.1 (Oracle Corporation 12.0.1+12)
OS:           Linux 4.19.0-5-amd64 amd64

Installing Gradle Manually via the Gradle Binary

Download Gradle Binary

To manually install Gradle using the binary, navigate to Grade releases page and grab the latest release binary. As of this writing, it is version 5.4.1. You can simply download the binary with wget command as follows.

wget https://downloads.gradle.org/distributions/gradle-5.4.1-bin.zip

Extract the Binary

Once the installation is done, extract the binary to install directory. This demo uses /opt/ directory.

unzip gradle-5.4.1-bin.zip -d /opt/

The Gradle 5.4.1 contents are extracted to /opt/gradle-5.4.1.

ls /opt/gradle-5.4.1
bin  getting-started.html  init.d  lib	LICENSE  media	NOTICE

Configure Gradle Environment Variables

Next, you need to create global Gradle home environment variable, GRADLE_HOME. You also need to add the Gradle bin directory to your PATH. These configs can be defined under the /etc/profile.d/ as a script.

vim /etc/profile.d/gradle.sh
export PATH=$PATH:/opt/gradle-5.4.1/bin
export GRADLE_HOME=/opt/gradle-5.4.1

Next, add the execute permissions to the script.

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

Once that is done, source the script to load the Gradle environment variables set.

source /etc/profile.d/gradle.sh

Next, verify the version of Gradle installed.

gradle -v
------------------------------------------------------------
Gradle 5.4.1
------------------------------------------------------------

Build time:   2019-04-26 08:14:42 UTC
Revision:     261d171646b36a6a28d5a19a69676cd098a4c19d

Kotlin:       1.3.21
Groovy:       2.5.4
Ant:          Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM:          12.0.1 (Oracle Corporation 12.0.1+12)
OS:           Linux 4.19.0-5-amd64 amd64

Well, you have successfully installed Gradle and that is all on how to install Gradle on Debian 10/9.

Reference:

Getting started with Gradle

LEAVE A REPLY

Please enter your comment!
Please enter your name here