Accelerating the developer’s productivity has to be the main task of a tool like Gradle. Since with it, we will be able to achieve the automation of several stages of the code made with Java. That is why, if you are a Java developer, you should know how to install Gradle on Ubuntu 20.04.
In the Github profile of the application, we find a quite understandable definition of what is Gradle
Gradle is a build tool with a focus on build automation and support for multi-language development. If you are building, testing, publishing, and deploying software on any platform, Gradle offers a flexible model that can support the entire development lifecycle from compiling and packaging code to publishing websites.
Although Gradle is intended to be used in Java, it also supports several languages such as Java, Scala, Android, Kotlin, C/C++, and Groovy, and is closely integrated with development tools and continuous integration servers including Eclipse, IntelliJ, and Jenkins.
So with Gradle, we can be more productive in the process of compiling and deploying the program.
Before starting, it is necessary to install two tools to continue the tutorial. The first one is
wget which is a tool to download files using the terminal; the second one is
unzip command with which we can unzip ZIP files from the terminal.
So, open a terminal from the main menu or by pressing the keys
CTRL + ALT + T and update Ubuntu.
sudo apt update sudo apt upgrade
After that, you can install both tools by running:
sudo apt install wget unzip
Gradle is built in Java so it is obvious that the system has it installed. To do this, we will make use of the OpenJDK which is available from the official Ubuntu repositories.
sudo apt install openjdk-11-jdk openjdk-11-jre
You can check if Java is working by displaying the version we just installed.
And the system is ready for Gradle installation. To do this, we need to go to the
From there with the
wget command we proceed to install the latest stable version of Gradle which at this moment is
Remember that the command will change when the stable version of Gradle changes.
After this, create the folder where Gradle will be located. It can be any folder you want. In this case, I will choose
sudo mkdir /opt/gradle
You can change
gradle to any name you want. And unzip the file in the newly created folder.
sudo unzip -d /opt/gradle gradle-6.8.3-bin.zip
So that we can use Gradle from the whole terminal prompt it is necessary to add the directory where the application is located to the user’s PATH.
In this way, Gradle will be installed and ready to be used by the user.
With Gradle installed, what we have to do now is to test if everything went well.
A quick way to do this is to show how the Gradle command works. It would be enough to show the version.
gradle -v Welcome to Gradle 6.8.3! Here are the highlights of this release: - Faster Kotlin DSL script compilation - Vendor selection for Java toolchains - Convenient execution of tasks in composite builds - Consistent dependency resolution For more details see https://docs.gradle.org/6.8.3/release-notes.html ------------------------------------------------------------ Gradle 6.8.3 ------------------------------------------------------------ Build time: 2021-02-22 16:13:28 UTC Revision: 9e26b4a9ebb910eaa1b8da8ff8575e514bc61c78 Kotlin: 1.4.20 Groovy: 2.5.12 Ant: Apache Ant(TM) version 1.10.9 compiled on September 27 2020 JVM: 11.0.10 (Ubuntu 11.0.10+9-Ubuntu-0ubuntu1.20.04) OS: Linux 5.4.0-66-generic amd64
This step confirms that Gradle is correctly installed in our system and that it can be used in our projects.
Developing applications requires tools that help with the process. One of them is Gradle with which we will be able to automate many situations that become routine and tedious for a developer. Also, Gradle is easy to install and is perfectly integrated with many popular tools such as Eclipse or IntelliJ IDEA.