In this article, we are going to perform How to Install Gradle on Ubuntu 24.04 LTS, Setup Environment variables for Gradle.
Gradle is build automation evolved. Gradle can automate the building, testing, publishing, deployment and more of software packages or other types of projects such as generated static websites, generated documentation or indeed anything else.
Table of Contents
Prerequisites
- Ubuntu Server 24.04 LTS
- SSH access with sudo privileges
Step#1:Install OpenJDK 21 on Ubuntu 24.04 LTS
Gradle requires Java to run. Ensure you have Java installed on your system.
sudo apt update
sudo apt install openjdk-21-jdk
verify java version.
java -version
Output:
ubuntu@ip-172-31-5-255:~$ java -version
openjdk version "11.0.24" 2024-07-16
OpenJDK Runtime Environment (build 11.0.24+8-post-Ubuntu-1ubuntu324.04.1)
OpenJDK 64-Bit Server VM (build 11.0.24+8-post-Ubuntu-1ubuntu324.04.1, mixed mode, sharing)
Step#2:Download and Install Gradle on Ubuntu 24.04 LTS
Download the gradle binary distribution on Ubuntu 24.04 LTS
wget https://services.gradle.org/distributions/gradle-8.10-bin.zip -P /tmp
output:
ubuntu@ip-172-31-5-255:~$ wget https://services.gradle.org/distributions/gradle-8.10-bin.zip -P /tmp
--2024-08-30 10:21:16-- https://services.gradle.org/distributions/gradle-8.10-bin.zip
Resolving services.gradle.org (services.gradle.org)... 104.16.73.101, 104.16.72.101, 2606:4700::6810:4965, ...
Connecting to services.gradle.org (services.gradle.org)|104.16.73.101|:443... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://github.com/gradle/gradle-distributions/releases/download/v8.10.0/gradle-8.10-bin.zip [following]
--2024-08-30 10:21:16-- https://github.com/gradle/gradle-distributions/releases/download/v8.10.0/gradle-8.10-bin.zip
Resolving github.com (github.com)... 20.207.73.82
Connecting to github.com (github.com)|20.207.73.82|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/696192900/795f5d1b-e62b-45cb-b014-d612f41cdf8e?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20240830%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240830T102116Z&X-Amz-Expires=300&X-Amz-Signature=25b6c4521f80c89f2f423af528a41cb1f3ca951b1efdc00b2205538ad3e0187c&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=696192900&response-content-disposition=attachment%3B%20filename%3Dgradle-8.10-bin.zip&response-content-type=application%2Foctet-stream [following]
--2024-08-30 10:21:16-- https://objects.githubusercontent.com/github-production-release-asset-2e65be/696192900/795f5d1b-e62b-45cb-b014-d612f41cdf8e?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20240830%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240830T102116Z&X-Amz-Expires=300&X-Amz-Signature=25b6c4521f80c89f2f423af528a41cb1f3ca951b1efdc00b2205538ad3e0187c&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=696192900&response-content-disposition=attachment%3B%20filename%3Dgradle-8.10-bin.zip&response-content-type=application%2Foctet-stream
Resolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.110.133, 185.199.111.133, 185.199.108.133, ...
Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.110.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 136713202 (130M) [application/octet-stream]
Saving to: ‘/tmp/gradle-8.10-bin.zip’
gradle-8.10-bin.zip 100%[====================================================================================================>] 130.38M 112MB/s in 1.2s
2024-08-30 10:21:18 (112 MB/s) - ‘/tmp/gradle-8.10-bin.zip’ saved [136713202/136713202]
Install unzip on Ubuntu if not installed.
sudo apt install unzip
Unzip the downloaded file.
sudo unzip -d /opt/gradle /tmp/gradle-8.10-bin.zip
Output:
ubuntu@ip-172-31-5-255:~$ sudo unzip -d /opt/gradle /tmp/gradle-8.10-bin.zip
Archive: /tmp/gradle-8.10-bin.zip
creating: /opt/gradle/gradle-8.10/
inflating: /opt/gradle/gradle-8.10/LICENSE
inflating: /opt/gradle/gradle-8.10/NOTICE
inflating: /opt/gradle/gradle-8.10/README
creating: /opt/gradle/gradle-8.10/init.d/
inflating: /opt/gradle/gradle-8.10/init.d/readme.txt
creating: /opt/gradle/gradle-8.10/bin/
inflating: /opt/gradle/gradle-8.10/bin/gradle
inflating: /opt/gradle/gradle-8.10/bin/gradle.bat
creating: /opt/gradle/gradle-8.10/lib/
inflating: /opt/gradle/gradle-8.10/lib/gradle-runtime-api-info-8.10.jar
inflating: /opt/gradle/gradle-8.10/lib/gradle-kotlin-dsl-extensions-8.10.jar
inflating: /opt/gradle/gradle-8.10/lib/gradle-gradle-cli-8.10.jar
inflating: /opt/gradle/gradle-8.10/lib/gradle-daemon-server-8.10.jar
inflating: /opt/gradle/gradle-8.10/lib/gradle-kotlin-dsl-8.10.jar
inflating: /opt/gradle/gradle-8.10/lib/gradle-tooling-api-provider-8.10.jar
inflating: /opt/gradle/gradle-8.10/lib/gradle-launcher-8.10.jar
inflating: /opt/gradle/gradle-8.10/lib/gradle-declarative-dsl-provider-8.10.jar
inflating: /opt/gradle/gradle-8.10/lib/gradle-client-services-8.10.jar
inflating: /opt/gradle/gradle-8.10/lib/gradle-build-state-8.10.jar
inflating: /opt/gradle/gradle-8.10/lib/gradle-daemon-services-8.10.jar
inflating: /opt/gradle/gradle-8.10/lib/gradle-daemon-protocol-8.10.jar
inflating: /opt/gradle/gradle-8.10/lib/gradle-toolchains-jvm-shared-8.10.jar
inflating: /opt/gradle/gradle-8.10/lib/gradle-build-events-8.10.jar
inflating: /opt/gradle/gradle-8.10/lib/gradle-tooling-api-8.10.jar
inflating: /opt/gradle/gradle-8.10/lib/gradle-problems-8.10.jar
inflating: /opt/gradle/gradle-8.10/lib/gradle-configuration-problems-base-8.10.jar
inflating: /opt/gradle/gradle-8.10/lib/gradle-core-8.10.jar
inflating: /opt/gradle/gradle-8.10/lib/gradle-jvm-services-8.10.jar
More....
Step#3:Setup Gradle Environment Variables on Ubuntu 24.04 LTS
Create a new environment variable script for gradle
sudo vi /etc/profile.d/gradle.sh
Add the below lines to script.
export GRADLE_HOME=/opt/gradle/gradle-8.10
export PATH=${GRADLE_HOME}/bin:${PATH}
Make the script executable.
sudo chmod +x /etc/profile.d/gradle.sh
Apply the changes.
source /etc/profile.d/gradle.sh
Step#4:Verify the Gradle installation
check the version for gradle.
gradle -v
Output:
ubuntu@ip-172-31-5-255:~$ gradle -v
Welcome to Gradle 8.10!
Here are the highlights of this release:
- Support for Java 23
- Faster configuration cache
- Better configuration cache reports
For more details see https://docs.gradle.org/8.10/release-notes.html
------------------------------------------------------------
Gradle 8.10
------------------------------------------------------------
Build time: 2024-08-14 11:07:45 UTC
Revision: fef2edbed8af1022cefaf44d4c0514c5f89d7b78
Kotlin: 1.9.24
Groovy: 3.0.22
Ant: Apache Ant(TM) version 1.10.14 compiled on August 16 2023
Launcher JVM: 11.0.24 (Ubuntu 11.0.24+8-post-Ubuntu-1ubuntu324.04.1)
Daemon JVM: /usr/lib/jvm/java-11-openjdk-amd64 (no JDK specified, using current Java home)
OS: Linux 6.8.0-1012-aws amd64
Conclusion:
In this article, we have covered How to Install Gradle on Ubuntu 24.04 LTS Configure environment variable for Gradle, verify gradle version on Ubuntu 24.04 LTS
Related Articles:
Reference: