11 C
Texas

How To Install Gradle on Ubuntu 18.04

What is Gradle?

Gradle is an open source build automation tool used for Java, Groovy and Scala development. Basically, it builds upon the concepts of Apache Ant & Apache Maven. Gradle uses Groovy instead of XML for declaring project configuration. Groovy is a dynamic, object-oriented programming language to define the project configurations. Follow the below steps to cover the Installation of Gradle on Ubuntu 18.04 / 16.04 / Linux Mint 19 & Debian

Requirements:

Java JDK or JRE version 7 or above.

Now, proceed to our Installation

Step 1: Update your system

Confirm that your system is updated

- Advertisement -
sudo apt update

Install OpenJDK package if you have not already installed by running

sudo apt install -y openjdk-8-jdk-headless

Confirm the Installation by

java -version

Output:

sabi@sabi:~$ java -version
openjdk version "1.8.0_232"
OpenJDK Runtime Environment (build 1.8.0_232-8u232-b09-0ubuntu1~18.04.1-b09)
OpenJDK 64-Bit Server VM (build 25.232-b09, mixed mode)

Install other required packages by typing

sudo apt install -y wget unzip

Step 2: Install Gradle on Ubuntu

Visit the official site of Gradle to Download the Gradle Binary-only zip file.

Download the latest version of Gradle v6.0.1

sabi@sabi:~$ wget https://services.gradle.org/distributions/gradle-6.0.1-bin.zip
--2019-12-28 11:43:18-- https://services.gradle.org/distributions/gradle-6.0.1-bin.zip
Resolving services.gradle.org (services.gradle.org)… 104.18.191.9, 104.18.190.9, 2606:4700::6812:be09, …
Connecting to services.gradle.org (services.gradle.org)|104.18.191.9|:443… connected.
HTTP request sent, awaiting response… 301 Moved Permanently
Location: https://downloads.gradle-dn.com/distributions/gradle-6.0.1-bin.zip [following]
--2019-12-28 11:43:19-- https://downloads.gradle-dn.com/distributions/gradle-6.0.1-bin.zip
Resolving downloads.gradle-dn.com (downloads.gradle-dn.com)… 104.17.160.20, 104.17.159.20, 2606:4700::6811:9f14, …
Connecting to downloads.gradle-dn.com (downloads.gradle-dn.com)|104.17.160.20|:443… connected.
HTTP request sent, awaiting response… 200 OK
Length: 95129672 (91M) [application/zip]
Saving to: ‘gradle-6.0.1-bin.zip’
gradle-6.0.1-bin.zi 100%[==================>] 90.72M 3.15MB/s in 42s
2019-12-28 11:44:04 (2.16 MB/s) - ‘gradle-6.0.1-bin.zip’ saved [95129672/95129672]

Move the downloaded package to working directory

sabi@sabi:~$ mv gradle-6.0.1-bin.zip /tmp/

After finishing download, extract the downloaded package in /opt/gradle directory using zip command

unzip gradle-*.zip 

Create a directory called /opt/gradle

 sudo mkdir /opt/gradle  

Copy the extracted files to the /opt/gradle

 sudo cp -pr gradle-*/* /opt/gradle 

You can confirm the extracted files by listing them in /opt/gradle directory.

sabi@sabi:/tmp$ cd /opt/gradle
sabi@sabi:/opt/gradle$ ls
bin getting-started.html init.d lib LICENSE NOTICE

Step 3: Setting Up Environment Variables

Configure the path environment variable to include the Gradle’s bin directory. For this create a new file inside the /etc/profile.d/ directory.

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

Paste the below data into the above file and save it.

export PATH=$PATH:/opt/gradle/gradle-6.0.1/bin

Type the given command to make the script executable.

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

Now, load the environment variables for the current session by

source /etc/profile.d/gradle.sh

Step 4: Verifying the Installation

Check the version of Gradle using gradle -v command

gradle -v

Output:

sabi@sabi:/tmp$ gradle -v
Welcome to Gradle 6.0.1!
Here are the highlights of this release:
Substantial improvements in dependency management, including
Publishing Gradle Module Metadata in addition to pom.xml
Advanced control of transitive versions
Support for optional features and dependencies
Rules to tweak published metadata
Support for Java 13
Faster incremental Java and Groovy compilation
New Zinc compiler for Scala
VS2019 support
Support for Gradle Enterprise plugin 3.0
For more details see https://docs.gradle.org/6.0.1/release-notes.html

Gradle 6.0.1
Build time: 2019-11-18 20:25:01 UTC
Revision: fad121066a68c4701acd362daf4287a7c309a0f5
Kotlin: 1.3.50
Groovy: 2.5.8
Ant: Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM: 1.8.0_232 (Private Build 25.232-b09)
OS: Linux 5.0.0-37-generic amd64
- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article