How to install Gradle on Debian 11
Gradle is an open-source tool for build automation in Java, Groovy, and Scala development. It relies on the concepts of Ant and Maven to automate the building process.
Unlike Apache Maven which relies on XML data files for declaring project configurations, Gradle uses Groovy, a dynamic programming language that defines project configurations.
In this post, we will guide you to install Gradle on Debian 11
Step 1: Update the repository
It is recommended to update the repository of Debian 11 once before using it so it can update the latest version of the packages. To update execute the following command:
apt update
Step 2: Installation of Java
Gradle requires Java as the prerequisite, so to install Java we will run the following command.
apt install default-jdk
Once the installation is complete and to verify the installation of Java, check the version of Java by command:
java -version
You should get the following output:
Step 3: Downloading Gradle
Here we will install the Gradle version (v7.2), if you want to download another version you can see the versions of Gradle here official site.
Install other required packages.
apt install -y curl unzip
Install Gradle
Use the below command in the terminal to download the Gradle (v7.2) package.
cd /tmp curl -O https://downloads.gradle-dn.com/distributions/gradle-7.2-bin.zip
Then, extract the package using the unzip
command.
unzip gradle-*.zip
Move the contents to /opt/gradle
directory.
mkdir /opt/gradle cp -pr gradle-*/* /opt/gradle
Verify the Gradle’s directory.
ls /opt/gradle/
Output:
Configure System Environment
We will now configure the PATH environment variable to include Gradle’s bin directory. To do that, execute the below command. If needed, replace Gradle’s bin path with your Gradle’s directory.
echo "export PATH=/opt/gradle/bin:${PATH}" | tee /etc/profile.d/gradle.sh
Make the script executable with chmod
command.
chmod +x /etc/profile.d/gradle.sh
Load the environment variables onto your current session by running the following command.
source /etc/profile.d/gradle.sh
To validate the Gradle installation, use the below command.
gradle -v
You should get the following output:
Conclusion
Gradle is the tool used to build the applications, it was launched in 2007 and is faster, more powerful, and more customizable than Ant, and Maven. Gradle is a much-improved tool than the previous tools used for build purposes like Apache Ant, Apache Maven, Grunt, and Gulp. This write-up discussed a method to install Gradle on Debian 11, simply installing Java and downloading the zip file from the official website of Gradle. Once the zip file is downloaded, make its configuration file, load it to install the Gradle, and then in the end validate the installation by checking its version. That’s All. You have successfully installed Gradle on Debian 11