Best DevOps

How To Install Gradle On Ubuntu

Source – linuxhelp.com

Gradle is a free and open source automation toolset based on Apache Ant and Apache Maven and builds support for development lifecycle. It uses domain specific language rather than XML form for project configuration. This tutorial explains the installation procedure of Gradle on Ubuntu.

Installation procedure

To start the installation procedure, first update the system repositories using the apt-get update command.

root@linuxhelp1:~# apt-get update
Hit:1 http://security.ubuntu.com/ubuntu xenial-security InRelease
Hit:2 http://in.archive.ubuntu.com/ubuntu xenial InRelease
Hit:3 http://in.archive.ubuntu.com/ubuntu xenial-updates InRelease
Hit:4 http://in.archive.ubuntu.com/ubuntu xenial-backports InRelease
Reading package lists... Done



The Gradle requires Java Development Kit version 7 or higher version to be installed. So use the below command to install JDK version 8.


root@linuxhelp1:~# apt-get install openjdk-8-jdk -y
Reading package lists... Done
Building dependency tree      
Reading state information... Done
The following additional packages will be installed:
  ca-certificates-java fonts-dejavu-extra java-common libbonobo2-0 libbonobo2-common libgif7 libgnome-2-0 libgnome2-common libgnomevfs2-0 libgnomevfs2-common libice-dev
  liborbit-2-0 libpthread-stubs0-dev libsm-dev libx11-dev libx11-doc libxau-dev libxcb1-dev libxdmcp-dev libxt-dev openjdk-8-jdk-headless openjdk-8-jre openjdk-8-jre-headless
  x11proto-core-dev x11proto-input-dev x11proto-kb-dev xorg-sgml-doctools xtrans-dev
Suggested packages:
  default-jre libbonobo2-bin desktop-base libgnomevfs2-bin libgnomevfs2-extra gamin | fam gnome-mime-data
.
.
.
Adding debian:NetLock_Notary_=Class_A=_Root.pem
Adding debian:Visa_eCommerce_Root.pem
Adding debian:PSCProcert.pem
Adding debian:QuoVadis_Root_CA_1_G3.pem
done.
Processing triggers for libc-bin (2.23-0ubuntu3) ...
Processing triggers for ca-certificates (20160104ubuntu1) ...
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.
done.

After installing Java check its version by running the following command.

root@linuxhelp1:~# java -version
openjdk version "1.8.0_121"
OpenJDK Runtime Environment (build 1.8.0_121-8u121-b13-0ubuntu1.16.04.2-b13)
OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode)

Next download the package for gradle using the below command.

root@linuxhelp1:~# wget https://services.gradle.org/distributions/gradle-3.4.1-bin.zip
--2017-04-06 18:00:22--  https://services.gradle.org/distributions/gradle-3.4.1-bin.zip
Resolving services.gradle.org (services.gradle.org)... 104.16.175.166, 104.16.174.166, 104.16.171.166, ...
Connecting to services.gradle.org (services.gradle.org)|104.16.175.166|:443... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://downloads.gradle.org/distributions/gradle-3.4.1-bin.zip [following]
--2017-04-06 18:00:23--  https://downloads.gradle.org/distributions/gradle-3.4.1-bin.zip
Resolving downloads.gradle.org (downloads.gradle.org)... 104.16.175.166, 104.16.172.166, 104.16.174.166, ...
Connecting to downloads.gradle.org (downloads.gradle.org)|104.16.175.166|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 70310446 (67M) [application/zip]
Saving to: ‘gradle-3.4.1-bin.zip’
gradle-3.4.1-bin.zip                          100%[===============================================================================================>]  67.05M   987KB/s    in 90s     
2017-04-06 18:01:53 (763 KB/s) - ‘gradle-3.4.1-bin.zip’ saved [70310446/70310446]

Now to install gradle inside /opt/ directory, create a directory for gradle inside /opt/ by running the following command.

root@linuxhelp1:~# mkdir /opt/gradle

Extract the package directly into /opt/gradle/ directory.

root@linuxhelp1:~# unzip -d /opt/gradle gradle-3.4.1-bin.zip
Archive:  gradle-3.4.1-bin.zip
   creating: /opt/gradle/gradle-3.4.1/
  inflating: /opt/gradle/gradle-3.4.1/LICENSE 
   creating: /opt/gradle/gradle-3.4.1/media/
  inflating: /opt/gradle/gradle-3.4.1/media/gradle-icon-16x16.png 
  inflating: /opt/gradle/gradle-3.4.1/media/gradle-icon-24x24.png 
  inflating: /opt/gradle/gradle-3.4.1/media/gradle.icns 
  inflating: /opt/gradle/gradle-3.4.1/media/gradle-icon-512x512.png 
  inflating: /opt/gradle/gradle-3.4.1/media/gradle-icon-32x32.png 
  inflating: /opt/gradle/gradle-3.4.1/media/gradle-icon-128x128.png 
  inflating: /opt/gradle/gradle-3.4.1/media/gradle-icon-64x64.png 
  inflating: /opt/gradle/gradle-3.4.1/media/gradle-icon-256x256.png
.
.
.
3.4.1/lib/plugins/xercesImpl-2.9.1.jar 
  inflating: /opt/gradle/gradle-3.4.1/lib/plugins/xml-apis-1.3.04.jar 
  inflating: /opt/gradle/gradle-3.4.1/lib/plugins/plexus-component-annotations-1.5.5.jar 
  inflating: /opt/gradle/gradle-3.4.1/lib/plugins/hamcrest-core-1.3.jar 
  inflating: /opt/gradle/gradle-3.4.1/lib/gradle-version-info-3.4.1.jar

To configure path environment variable, run the following command and execute the variable.

root@linuxhelp1:~# export PATH=$PATH:/opt/gradle/gradle-3.4.1/bin

Now gradle is installed on the target machine. Verify it’s version using the below command.

root@linuxhelp1:~# gradle -v
------------------------------------------------------------
Gradle 3.4.1
------------------------------------------------------------
Build time:   2017-03-03 19:45:41 UTC
Revision:     9eb76efdd3d034dc506c719dac2955efb5ff9a93
Groovy:       2.4.7
Ant:          Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM:          1.8.0_121 (Oracle Corporation 25.121-b13)
OS:           Linux 4.4.0-21-generic amd64

Wasn’t that an easy installation? Gradle is designed to use multi project builds that can grow to a substantial size.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.