Contents
Gradle is an open-source build tool for automating applications. Gradle helps teams of developers build, automate and deliver software more easily and quickly, increasing their productivity. It can build applications written in Java, C++, Python or your own language.
This tutorial will help you install Gradle on an Ubuntu 20.04 LTS system.
You may also like:
Prerequisites
You must have root or sudo privileged account access on the Ubuntu 20.04 system.
Gradle requires Java to run on any operating system. First of all, make sure Java is installed on your system. Also make sure you have installed both the JDK and JRE.
java -version openjdk 11.0.7 2020-04-14 OpenJDK Runtime Environment (build 11.0.7+10-post-Ubuntu-3ubuntu1) OpenJDK 64-Bit Server VM (build 11.0.7+10-post-Ubuntu-3ubuntu1, mixed mode, sharing)
If the Java Development Kit is not installed on your system, use the following command to install it.
sudo apt install default-jdksudo apt install default-jdk
Step 1 – Install Gradle on Ubuntu 20.04
After Java is installed, download the binary of the latest Gradle distribution release from the official download page.
wget https://downloads.gradle-dn.com/distributions/gradle-6.4.1-bin.zip
Then extract the downloaded archive and place it in the proper location. I usually use the /usr/local directory to store applications. You can use an alternative directory such as /opt.
unzip gradle-6.4.1-bin.zip mv gradle-6.4.1 /usr/local/gradle
Gradle is now set up on your system.
Step 2 – Set Up the Environment Variable
Next, you need to set up Gradle in the PATH environment variable. Also make sure the variable is still set after the system is rebooted.
To set the PATH variable across reboots, place a shell script under the profile.d directory. Create a file as follows:
vim /etc/profile.d/gradle.sh
and add the following line to the file
export PATH=/usr/local/gradle/bin:$PATH
Save and close the file. Now source the script to apply the environment to the current shell.
source /etc/profile.d/gradle.sh
And you have completed the Gradle installation on your Ubuntu system.
Step 3 – Test the Gradle Installation
Gradle has been successfully set up on your system. Use the Gradle tool to build your applications. Let's check the version installed on your system.
gradle -v
Output
Welcome to Gradle 6.4.1! Here are the highlights of this release: - Support for building, testing and running Java Modules - Precompiled script plugins for Groovy DSL - Single dependency lock file per project For more details see https://docs.gradle.org/6.4.1/release-notes.html ------------------------------------------------------------ Gradle 6.4.1 ------------------------------------------------------------ Build time: 2020-05-15 19:43:40 UTC Revision: 1a04183c502614b5c80e33d603074e0b4a2777c5 Kotlin: 1.3.71 Groovy: 2.5.10 JVM: 11.0.7 (Ubuntu 11.0.7+10-post-Ubuntu-3ubuntu1) OS: Linux 5.4.0-26-generic amd64
Conclusion
In this tutorial, you learned how to install and configure Gradle on your Ubuntu 20.04 system.