This is a step-by-step tutorial on how to set up Gradle on your machine. Gradle is the most popular build automation tool in recent times as it has advantages over the Maven build tool.
Note: Make sure you are on Java 8 or a later version.
Navigate to https://gradle.org/releases/ and download the latest version of gradle
Unzip and setup:
$ mkdir /opt/gradle
$ unzip -d /opt/gradle gradle-7.6-bin.zip
$ ls /opt/gradle/gradle-7.6
LICENSE NOTICE bin getting-started.html init.d lib media
Set path variable
export PATH=$PATH:/opt/gradle/gradle-7.6/bin
verify
$ gradle -v
This will result in the below status showing the version of the installed Gradle.
Welcome to Gradle 7.6!
Here are the highlights of this release:
- Added support for Java 19.
- Introduced `--rerun` flag for individual task rerun.
- Improved dependency block for test suites to be strongly typed.
- Added a pluggable system for Java toolchains provisioning.
For more details see https://docs.gradle.org/7.6/release-notes.html
------------------------------------------------------------
Gradle 7.6
------------------------------------------------------------
Build time: 2022-11-25 13:35:10 UTC
Revision: daece9dbc5b79370cc8e4fd6fe4b2cd400e150a8
Kotlin: 1.7.10
Groovy: 3.0.13
Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM: 11.0.16 (Oracle Corporation 11.0.16+11-LTS-199)
OS: Mac OS X 13.0 aarch64
If you want to add to .bash_profile
and create GRADLE_HOME and set up the path so that every time you open terminal Gradle will be available follow the below steps to create GRADLE_HOME
open .bash_profile
on a terminal using vi editor
vi .bash_profile
Once you open the file edit with the command i add the below lines to set the GRADLE_HOME
export GRADLE_HOME=/opt/gradle/gradle-7.6
export PATH=$GRADLE_HOME/bin:$PATH
and save the file with :wq command
then hit the source .bash_profile
command to set the variables to current opened terminal
gradle -v
------------------------------------------------------------
Gradle 7.6
------------------------------------------------------------
Build time: 2022-11-25 13:35:10 UTC
Revision: daece9dbc5b79370cc8e4fd6fe4b2cd400e150a8
Kotlin: 1.7.10
Groovy: 3.0.13
Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM: 11.0.16 (Oracle Corporation 11.0.16+11-LTS-199)
OS: Mac OS X 13.0 aarch64
Now every time you open the system terminal Gradle is ready to run the commands.