11.6 C
Jaipur
Wednesday, December 8, 2021

How to Install Gradle on Debian 11

Must read

Gradle is a general-purpose build tool with a focus on Java projects. It is built in a Groovy or Kotlin domain-specific language but can be used to support other languages also.

The following are some of the main features of this build automation tool.

  • Its multi-platform, meaning you can run it on any platform regardless of the OS e.g. Windows, Linux, or Mac OS X.
  • It supports incremental builds by determining which outputs are out of date and building only those inputs that are out of date or new.
  • It has support for build scans which means it can show you what your builds dependencies are so that you can only depend on the ones you need for your project.
  • It has the ability to build in parallel by splitting different tasks into different parts and then running them simultaneously. For example, you can process source files in one task while processed resources are moved through another task for processing in a separate thread.

This article describes how to install Gradle on Debian. This guide should work on other Debian-based systems as well, as long as the version of Gradle being installed is above 3.0.

Prerequisites

  • The following are the minimum prerequisites for this article that you need to have installed on your machine.
  • A non-root user with sudo privileges is set up on your machine.
  • At least 1 GB of RAM is available in order to successfully install Gradle.

Updating Your System

For this article to work successfully on your machine, you need to ensure that all the packages on your system are up-to-date. To do this, run the following command:

sudo apt update && sudo apt upgrade -y

You should see a log showing what packages have been upgraded and also which ones were installed if anything new was available.

Installing Java

Gradle requires that the Java Development Kit (JDK) be installed on your machine. You can check whether Java is installed on your machine by running the following command:

java -version

If JDK is not found on your machine, install Java on Debian run the following command:

sudo apt install default-jdk -y

The entire process will take a few minutes to complete. You can verify that Java is installed on Debian 11 by checking the version of the java.

java -version

You should see a log showing the version of Java you’ve just installed and also its Runtime Environment (JRE).

Installing Gradle

We will create the /opt/gradle directory to hold the Gradle installation files. Then you move into the directory and download the Gradle files using the wget command. And extract the zip file using the unzip command.

sudo mkdir /opt/gradle
cd /opt/gradle
wget https://downloads.gradle-dn.com/distributions/gradle-7.2-bin.zip
unzip gradle-7.2-bin.zip

To verify that Gradle is successfully extracted on Debian 11, run the following command:

ls /opt/gradle/

list files

Now, you will need to set up the environment using the PATH environment variable. To do this, we will add the Gradle bin directory to /etc/profile.d by running the following command:

echo "export PATH=/opt/gradle/bin:${PATH}" | sudo tee /etc/profile.d/gradle.sh

Make the gradle.sh file executable by running the following command:

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

Next, load the environment variables using the source command :

source /etc/profile.d/gradle.sh

Now, whenever you log in to your system, Gradle should already be added to the PATH environment variable and thus available for you to use.

Once the installation is done. You can verify the Gradle installation by running the following command:

gradle -v

This command will give you an output similar to this one:

gradle version

Congratulations! Gradle has now been successfully installed on your machine.

Conclusion

This article described how to install Gradle on Debian 11. You can now use Gradle to make your development tasks easier and more efficient.

If you have any questions, feel free to leave a comment below.

Source link

- Advertisement -

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement -

Latest article