How to Install Gradle on Ubuntu 18.04 | 20.04

How to Install Gradle on Ubuntu 18.04 20.04

This post shows users and new students that how to Install Gradle on Ubuntu 18.04 | 20.04. If you’re going to Install Gradle on Ubuntu then this post is ideal for you.

Gradle is an open source and advanced general-purpose build automation management system for multi-language software development. It is based on Groovy and Kotlin. It is supported many languages include Java, C/C++ and JavaScript.

Gradle is also works with many popular IDE platforms including, Android Studio, Eclipse, IDEA and NetBeans.

For more details about Gradle, please go to its official website.

Follow the below steps for starting to Install Gradle on Ubuntu 18.04 | 20.04:

Step 1: Install Java JDK

If you want to use Apache Groove properly, then first, you will need Java JDK installed on Ubuntu. So download the Java JDK 7 and above.

Here we are going to use OpenJDK for this post, so run the below command to install OpenJDK 8.

sudo apt update
sudo apt install openjdk-8-jdk

After finish the installing Java, you can check it by running the below commands :

java -version

When you run above command, it will show the result similar as below:

openjdk version "1.8.0_181"
OpenJDK Runtime Environment (build 1.8.0_181-8u181-b13-0ubuntu0.18.04.1-b13)
OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode)

Step 2: Install Gradle

After installing of OpenJDK 8, Now run the below commands to download Gradle. At this time, the Gradle version is 6.7.1

cd /tmp
wget https://services.gradle.org/distributions/gradle-6.7.1-bin.zip

After Downloading, extract the content in the /opt director.

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

When you run the above command it will be extracted the content in the /opt/gradle/gradle-6.7.1 directory.

Step 3: Configure Ubuntu Environment Variables

To configure Ubuntu environment variables for use Gradle, simply you can do that by running the below commands to create a new file that is called gradle.sh in the /etc/profile.d directory.

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

After creating file, copy and pastes the below lines into the file and save it.

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

Now, run the below commands to make the file executable.

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

Now are able to use Gradle on Ubuntu. For check Gradle version and its info, run the below command.

gradle -v

The above command should show a message similar as below:

Welcome to Gradle 6.7.1!

Here are the highlights of this release:
 - Incremental Java compilation by default
 - Periodic Gradle caches cleanup
 - Gradle Kotlin DSL 1.0-RC6
 - Nested included builds
 - SNAPSHOT plugin versions in the `plugins {}` block

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


------------------------------------------------------------
Gradle 6.7.1
------------------------------------------------------------

Build time:   2018-09-19 18:10:15 UTC
Revision:     b4d8d5d170bb4ba516e88d7fe5647e2323d791dd

Kotlin DSL:   1.0-rc-6
Kotlin:       1.2.61
Groovy:       2.4.15
Ant:          Apache Ant(TM) version 1.9.11 compiled on March 23 2018
JVM:          1.8.0_181 (Oracle Corporation 25.181-b13)
OS:           Linux 4.15.0-36-generic amd64

That’s all

If you find any error and issue in above steps , please use comment box below to report.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

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