Install Gradle on Rocky Linux 8

0
34

In this blog post, you will learn how to install Gradle on Rocky Linux 8. According to the documentation page, “Gradle is an open-source build automation tool focused on flexibility and performance. Gradle build scripts are written using a Groovy or Kotlin DSL.”

Some of the Gradle’s features include but not limited to;

  • Highly customizable — Gradle is modeled in a way that is customizable and extensible in the most fundamental ways.
  • Fast — Gradle completes tasks quickly by reusing outputs from previous executions, processing only inputs that changed, and executing tasks in parallel.
  • Powerful — Gradle is the official build tool for Android, and comes with support for many popular languages and technologies.

Read more on features page.

Install Gradle on Rocky Linux 8

Install Java JDK on Rocky Linux 8

Gradle requires Java 8 or higher to run. In this demo, we will be using Java 11.

java -version
openjdk version "11.0.11" 2021-04-20 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.11+9-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.11+9-LTS, mixed mode, sharing)

To install Java JDK 11 on Rocky Linux 8, which is available on the default Rocky Linux 8 AppStream repos, run the command below to install Java 11 on Rocky Linux 8.

dnf install java-11-openjdk-devel

Install Gradle on Rocky Linux 8

There are different ways in which you can install Gradle on Rocky Linux 8:

  1. Using SDMAN! package manager
  2. Using Binary File

Install Gradle on Rocky Linux 8 using SDMAN! Package Manager

To install Gradle using SDMAN! package manager, proceed as follows.

Install SDMAN! package manager on Rocky Linux 8.

dnf install zip
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"

To confirm that SDKMAN! package manager is installed and working fine, run the command;

sdk help
Usage: sdk  [candidate] [version]
       sdk offline 

   commands:
       install   or i     [version] [local-path]
       uninstall or rm    
       list      or ls   [candidate]
       use       or u     
       config
       default   or d     [version]
       home      or h     
       env       or e    [init|install|clear]
       current   or c    [candidate]
       upgrade   or ug   [candidate]
       version   or v
       broadcast or b
       help
       offline           [enable|disable]
       selfupdate        [force]
       update
       flush             [archives|tmp|broadcast|version]

   candidate  :  the SDK to install: groovy, scala, grails, gradle, kotlin, etc.
                 use list command for comprehensive list of candidates
                 eg: $ sdk list
   version    :  where optional, defaults to latest stable if not provided
                 eg: $ sdk install groovy
   local-path :  optional path to an existing local installation
                 eg: $ sdk install groovy 2.4.13-local /opt/groovy-2.4.13

Once the SDMAN! package manager is installed, then install Gradle;

First, check the current stable release version of Gradle on the releases page. As of this writing, Gradle 7.1.1 is the current stable release.

You can also list available version using the package manager;

sdk list gradle

Hence, replace the value of the VER variable below with the specific version of Gradle you are installing and execute the installation command;

VER=7.1.1
sdk install gradle $VER

Once the installation is done, you can now start using Gradle. For example, to verify the installed version, run the command below;

gradle -v
Welcome to Gradle 7.1.1!

Here are the highlights of this release:
 - Faster incremental Java compilation
 - Easier source set configuration in the Kotlin DSL

For more details see https://docs.gradle.org/7.1.1/release-notes.html


------------------------------------------------------------
Gradle 7.1.1
------------------------------------------------------------

Build time:   2021-07-02 12:16:43 UTC
Revision:     774525a055494e0ece39f522ac7ad17498ce032c

Kotlin:       1.4.31
Groovy:       3.0.7
Ant:          Apache Ant(TM) version 1.10.9 compiled on September 27 2020
JVM:          11.0.11 (Red Hat, Inc. 11.0.11+9-LTS)
OS:           Linux 4.18.0-305.7.1.el8_4.x86_64 amd64

Install Gradle on Rocky Linux using Binary Files

Download the latest release file from Gradle release page.

VER=7.1.1
wget https://downloads.gradle-dn.com/distributions/gradle-$VER-bin.zip -P /tmp

Extract the binary files;

unzip -d /opt/ /tmp/gradle-7.1.1-bin.zip
mv /opt/gradle{-7.1.1,}

Update the PATH environment variable to include path to Gradle binary files directory, /opt/gradle/bin/.

echo 'export PATH=$PATH:/opt/gradle/bin' > /etc/profile.d/gradle.sh
chmod +x /etc/profile.d/gradle.sh
source /etc/profile.d/gradle.sh

Checking the version;

gradle -v

You can consult Gradle User Manual for usage information.

That marks the end of our tutorial on how to install Gradle on Rocky Linux 8.

Other Tutorials

Install Gradle on Debian 10/9

How to Install Yarn on Debian 10 Buster

LEAVE A REPLY

Please enter your comment!
Please enter your name here