How to Install Gradle on Debian 10
Choose a different version or distribution
Introduction
Before we begin talking about how to install Gradle on Debian 10, let's briefly understand – What is Gradle?
Gradle is a powerful build automation tool used in software development. It simplifies the process of compiling, testing, and deploying applications. With its flexibility and efficient dependency management, Gradle allows developers to customize their build workflows.
It supports various programming languages, making it popular among Java, Android, and Kotlin developers. Whether you're a beginner or an experienced developer, Gradle empowers you to automate and streamline your project builds, saving time and effort.
In this tutorial, you will install Gradle on Debian 10 Linux. We will also address a few FAQs on how to install Gradle on Debian 10.
Advantages of Gradle
- Efficient Dependency Management: Gradle simplifies handling project dependencies, ensuring that required libraries and frameworks are seamlessly integrated.
- Customizable Build Workflows: Gradle offers flexibility to define and customize build workflows, adapting to project-specific requirements.
- Multi-Language Support: Gradle supports multiple programming languages, including Java, Android, and Kotlin, making it versatile for various development environments.
- Incremental Builds: Gradle intelligently builds only the necessary components, saving time by avoiding recompilation of unchanged code.
- Rich Plugin Ecosystem: Gradle provides a vast collection of plugins that extend its functionality, enabling integration with popular tools and frameworks.
Prerequisites to Install Gradle on Debian 10
The tutorial presumes you are logged in as root or a user with sudo privileges.
Installing OpenJDK
Java SE 8 or higher must be installed on the server in order to use Gradle.
To install the OpenJDK package, enter the following command:
sudo apt update
sudo apt install default-jdk
Run the following command to confirm the Java installation:
java -version
The screen will display the following output:
Output
openjdk version "11.0.6" 2020-01-14
OpenJDK Runtime Environment (build 11.0.6+10-post-Debian-1deb10u1)
OpenJDK 64-Bit Server VM (build 11.0.6+10-post-Debian-1deb10u1, mixed mode, sharing)
Downloading Gradle
The most recent version of Gradle is 7.6
at the time of writing this tutorial. You should check the Gradle releases page to see if a newer version is available before moving on to the next step.
Use the wget
command shown below to download the Gradle binary file:
wget https://services.gradle.org/distributions/gradle-6.3-bin.zip -P /tmp
Extract the zip file in the /opt/gradle
directory after the download is finished:
sudo apt install unzip
sudo unzip -d /opt/gradle /tmp/gradle-*.zip
Check to see if the Gradle files have been extracted:
ls /opt/gradle/gradle-*
Output
bin init.d lib LICENSE NOTICE README
Setting up the Environment Variables
The next step is to configure the PATH environment variable to include the Gradle bin directory. Open your text editor and create a new file called gradle.sh
in the /etc/profile.d
directory to accomplish this.
sudo nano /etc/profile.d/gradle.sh
Paste the configuration shown below:
export GRADLE_HOME=/opt/gradle/gradle-6.3
export PATH=${GRADLE_HOME}/bin:${PATH}
Save the document, then exit. The script will be sourced during shell startup.
Run the chmod
command to the script executable:
sudo chmod +x /etc/profile.d/gradle.sh
The source
command should be used to load the environment variables:
source /etc/profile.d/gradle.sh
Verifying the Gradle Installation
Run the following command to see the Gradle version and check that Gradle is installed correctly:
gradle -v
The output should resemble something like shown below:
Output
Welcome to Gradle 6.3!
Here are the highlights of this release:
- Java 14 support
- Improved error messages for unexpected failures
For more details see https://docs.gradle.org/6.3/release-notes.html
------------------------------------------------------------
Gradle 6.3
------------------------------------------------------------
Build time: 2023-06-14 19:52:07 UTC
Revision: bacd40b727b0130eeac8855ae3f9fd9a0b207c60
Kotlin: 1.3.70
Groovy: 2.5.10
Ant: Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM: 11.0.6 (Debian 11.0.6+10-post-Debian-1deb10u1)
OS: Linux 4.19.0-6-amd64 amd64
Congratulations! Gradle is successfully installed on your Debian 10 system and is ready to use.
FAQs to Install Gradle on Debian 10
What version of Java is required for Gradle on Debian 10?
Gradle requires Java 8 or higher. You can install OpenJDK 11 on Debian 10 as the recommended version.
Can I install Gradle using a package manager like apt-get?
Unfortunately, Gradle is not available in the official Debian repositories. You need to install it manually by downloading the binary distribution.
Can I have multiple versions of Gradle installed on Debian 10?
Yes, you can have multiple versions of Gradle installed on Debian 10 by downloading and configuring each version separately. Make sure to update the environment variables accordingly.
How can I upgrade Gradle to a newer version on Debian 10?
To upgrade Gradle, download the new binary distribution, unzip it, and replace the existing Gradle installation directory (/opt/gradle
) with the new one. Update the environment variables in /etc/profile
accordingly.
Can I uninstall Gradle from Debian 10?
Yes, you can uninstall Gradle by removing its installation directory (/opt/gradle) and deleting the corresponding environment variable settings from /etc/profile
.
Does Gradle require an internet connection for installation on Debian 10?
Gradle requires an internet connection to download the binary distribution. Once installed, it can work offline, utilizing locally cached dependencies.
Can I use Gradle to build projects written in languages other than Java on Debian 10?
Yes, Gradle supports building projects in various programming languages, including but not limited to Java. It can be used with languages like Kotlin, Groovy, Scala, and more.
Conclusion
You now know how to install Gradle on Debian 10. To learn how to get started with Gradle, visit the official Gradle Documentation page.
If you have any queries, please leave a comment below, and we’ll be happy to respond to them.