12 C
Texas
angeloma
Senior Writer and partner

How to install Gradle on Ubuntu 20.04?

Hi, folks. In this post dedicated to Java, you will learn how to install Gradle on Ubuntu 20.04

Gradle is an open-source build automation tool used for Java, Groovy, and Scala development. Basically, it builds upon the concepts of Apache Ant & Apache Maven. Gradle uses Groovy instead of XML for declaring the project configuration. Groovy is a dynamic, object-oriented programming language to define the project configurations.

So, let us start.

Installing Gradle on Ubuntu 20.04

Gradle is important for the effective development of Java applications. So the first requirement is to install Java on Ubuntu 20.04.

- Advertisement -

So, open a terminal and install it using the following command:

:~$ sudo apt install openjdk-11-jre
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following additional packages will be installed:
at-spi2-core ca-certificates-java fonts-dejavu-extra java-common libatk-bridge2.0-0 libatk-wrapper-java libatk-wrapper-java-jni libatk1.0-0 libatk1.0-data
libatspi2.0-0 libavahi-client3 libavahi-common-data libavahi-common3 libcups2 libdrm-amdgpu1 libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libfontenc1 libgif7 libgl1
libgl1-mesa-dri libglapi-mesa libglvnd0 libglx-mesa0 libglx0 libice6 liblcms2-2 libllvm10 libnspr4 libnss3 libpciaccess0 libpcsclite1 libsensors-config libsensors5
libsm6 libvulkan1 libwayland-client0 libx11-xcb1 libxaw7 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-present0 libxcb-randr0 libxcb-shape0 libxcb-sync1
libxcomposite1 libxdamage1 libxfixes3 libxft2 libxi6 libxinerama1 libxkbfile1 libxmu6 libxrandr2 libxrender1 libxshmfence1 libxt6 libxtst6 libxv1 libxxf86dga1
libxxf86vm1 mesa-vulkan-drivers openjdk-11-jre-headless x11-common x11-utils
Suggested packages:
default-jre cups-common liblcms2-utils pcscd lm-sensors libnss-mdns fonts-ipafont-gothic fonts-ipafont-mincho fonts-wqy-microhei | fonts-wqy-zenhei fonts-indic
mesa-utils
The following NEW packages will be installed:
at-spi2-core ca-certificates-java fonts-dejavu-extra java-common libatk-bridge2.0-0 libatk-wrapper-java libatk-wrapper-java-jni libatk1.0-0 libatk1.0-data
libatspi2.0-0 libavahi-client3 libavahi-common-data libavahi-common3 libcups2 libdrm-amdgpu1 libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libfontenc1 libgif7 libgl1
libgl1-mesa-dri libglapi-mesa libglvnd0 libglx-mesa0 libglx0 libice6 liblcms2-2 libllvm10 libnspr4 libnss3 libpciaccess0 libpcsclite1 libsensors-config libsensors5
libsm6 libvulkan1 libwayland-client0 libx11-xcb1 libxaw7 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-present0 libxcb-randr0 libxcb-shape0 libxcb-sync1
libxcomposite1 libxdamage1 libxfixes3 libxft2 libxi6 libxinerama1 libxkbfile1 libxmu6 libxrandr2 libxrender1 libxshmfence1 libxt6 libxtst6 libxv1 libxxf86dga1
libxxf86vm1 mesa-vulkan-drivers openjdk-11-jre openjdk-11-jre-headless x11-common x11-utils
0 upgraded, 68 newly installed, 0 to remove and 86 not upgraded.
Need to get 71.3 MB of archives.
After this operation, 555 MB of additional disk space will be used.
Do you want to continue? [Y/n]
1.- Installing Java on Ubuntu 20.04
1.- Installing Java on Ubuntu 20.04

Once you have entered your password, the installation will begin.

When the installation is finished, you can check the version of Java installed:

:~$ java --version
openjdk 11.0.8 2020-07-14
OpenJDK Runtime Environment (build 11.0.8+10-post-Ubuntu-0ubuntu120.04)
OpenJDK 64-Bit Server VM (build 11.0.8+10-post-Ubuntu-0ubuntu120.04, mixed mode, sharing)

This indicates that Java is ready for action.

Downloading and installing Gradle on Ubuntu 20.04

Now the next step is to download and install Gradle. To do this, go to the /tmp/ folder and use the wget command to download:

:~$ wget -c https://services.gradle.org/distributions/gradle-6.5.1-bin.zip
--2020-08-02 19:24:17-- https://services.gradle.org/distributions/gradle-6.5.1-bin.zip
Resolving services.gradle.org (services.gradle.org)… 104.18.191.9, 104.18.190.9, 2606:4700::6812:bf09, …
Connecting to services.gradle.org (services.gradle.org)|104.18.191.9|:443… connected.
HTTP request sent, awaiting response… 301 Moved Permanently
Location: https://downloads.gradle-dn.com/distributions/gradle-6.5.1-bin.zip [following]
--2020-08-02 19:24:18-- https://downloads.gradle-dn.com/distributions/gradle-6.5.1-bin.zip
Resolving downloads.gradle-dn.com (downloads.gradle-dn.com)… 104.17.160.20, 104.17.159.20, 2606:4700::6811:9f14, …
Connecting to downloads.gradle-dn.com (downloads.gradle-dn.com)|104.17.160.20|:443… connected.
HTTP request sent, awaiting response… 200 OK
Length: 102367135 (98M) [application/zip]
Saving to: ‘gradle-6.5.1-bin.zip’
gradle-6.5.1-bin.zip 100%[=====================================================================================>] 97.62M 841KB/s in 2m 2s
2020-08-02 19:26:21 (821 KB/s) - ‘gradle-6.5.1-bin.zip’ saved [102367135/102367135]
2.- Download and installing Gradle on Ubuntu 20.04
2.- Download and installing Gradle on Ubuntu 20.04

At the time of writing this post, the latest stable version of Gradle is 6.5.1 So, check first which is the latest version and modify the command.

If you don’t have the unzip command installed, do it because we will need it.

sudo apt install unzip

Now unzip the downloaded file into a directory like /opt/ where it will remain indefinitely:

:~$ sudo unzip -d /opt/gradle gradle-6.5.1-bin.zip

The next step is to make Gradle available from anywhere in the terminal. Also, make it available to all users.

To do this, create a new file called gradle.sh in /etc/profile.d/

:~$ sudo nano /etc/profile.d/gradle.sh

And add the following content:

export GRADLE_HOME=/opt/gradle/gradle-6.5.1
export PATH=${GRADLE_HOME}/bin:${PATH}
3.- Configuring Gradle
3.- Configuring Gradle

Save the changes, and close the editor.

Assign execution permissions to the file:

:~$ sudo chmod +x /etc/profile.d/gradle.sh

And finally, source the file to apply the changes:

:~$ source /etc/profile.d/gradle.sh

Now you can use Gradle from the terminal. So, check the installation, showing the version of the program:

:~$ gradle -v
Welcome to Gradle 6.5.1!
Here are the highlights of this release:
Experimental file-system watching
Improved version ordering
New samples
For more details see https://docs.gradle.org/6.5.1/release-notes.html

Gradle 6.5.1
Build time: 2020-06-30 06:32:47 UTC
Revision: 66bc713f7169626a7f0134bf452abde51550ea0a
Kotlin: 1.3.72
Groovy: 2.5.11
Ant: Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM: 11.0.8 (Ubuntu 11.0.8+10-post-Ubuntu-0ubuntu120.04)
OS: Linux 5.4.0-33-generic amd64
4.- Gradle on Ubuntu 20.04
4.- Gradle on Ubuntu 20.04

So, enjoy it. Gradle is installed and ready to start work.

Conclusion

Gradle is a tool for the development of Java applications. So, thanks to this post, you have learned how to install it in a system like Ubuntu 20.04 that is so popular among Java developers.

So, share this post, and join our Telegram Channel.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article