Gradle is a build automation tool that is used to build different applications, from mobile applications to microservices. Gradle provides a platform to build, test, and maintain the applications; moreover, if you are working on a multi-build project, Gradle looks continuously at the project, and if you made any changes, even the minor changes, Gradle provides the output according to those changes.
Gradle improves the performance of applications by allowing the parallel execution of tasks and intra-tasks through a worker API, and every time can be limited to the execution time as these tasks have their own timeout property.
Gradle can be installed on different distributions of Linux, but in this guide, we are focusing on discovering the installation of Gradle on Ubuntu.
How to install Gradle on Ubuntu 22.04 from its official website
We will install Gradle by downloading its package from its official website, for this purpose, we will execute the following steps.
Step 1: Install Java on Ubuntu
Gradle is dependent on the Java, so we will first install the latest version of Java available in the default repository of Ubuntu using the command:
We will check out the version of an installed package of Java:
Step 2: Download Gradle package
Now after installing the Java, we will download the package of Gradle from its official website in the tmp directory of Ubuntu using the wget command:
We will list down the downloaded package to confirm its downloading:
Step 3: Unzip the downloaded package of Gradle
The downloaded package is zipped, we will unzip it using the command:
Now again list down the unzipped files by executing the ls command:
Step 4: Set up environment variables
Next step is to set up the environment variables, for this we will make some changes in the “sh” file of Gradle and for this we have to open it with the nano text editor:
In the opened file, add the below-mentioned two lines and then exit the editor by saving the changes made in the file:
export PATH=${GRADLE_HOME}/bin:${PATH}
Step 5: Change the permissions of file
To make the “sh” file executable, we will change its permissions using the chmod command:
Step 6: Install the Gradle
Finally, load the environment variables using:
To confirm the installation, we will check the version of installed Gradle:
How to install Gradle on Ubuntu 22.04 using the snap
Another method to install Gradle on Ubuntu is by downloading and installing it from the snapcraft, and for this purpose, we need a snapd utility which can be installed by using the command:
To download and install the snap of Gradle from snapcraft, execute the command:
To remove the installed package of Gradle, use the command:
Conclusion
Gradle is a tool used to build, automate, test, and maintain the applications, whether they are mobile applications or applications designed to provide microservices. In this guide, Gradle’s installation method on Ubuntu has been explored by downloading its package from its official website.