Yes, there are two main ways to use Gradle:
1. Installing Gradle and setting the classpath:
This is the traditional way to use Gradle. In this approach, you install Gradle globally on your system and set the classpath to include the Gradle installation directory. This allows you to run Gradle commands from any directory on your system.
To install Gradle globally, you can download the Gradle distribution from the Gradle website and follow the installation instructions for your operating system. Once Gradle is installed, you can set the classpath by adding the following line to your ~/.bashrc or ~/.zshrc file:
Bash
export PATH="$HOME/.gradle/bin:$PATH"
This will add the Gradle bin directory to your system path, allowing you to run Gradle commands by simply typing gradle followed by the command you want to execute.
2. Using the Gradle wrapper:
The Gradle wrapper is a script that is included in the root directory of a Gradle project. It allows you to run Gradle commands without having Gradle installed globally. This is useful for projects that need to be portable or for developers who do not want to install Gradle globally.
To use the Gradle wrapper, you simply run the gradlew script in the root directory of your project. This script will download and run the Gradle distribution that is required for your project.
Which approach you use depends on your preferences and the specific needs of your project. If you are working on multiple Gradle projects, it may be more convenient to install Gradle globally and set the classpath. However, if you are only working on a single Gradle project, it may be easier to use the Gradle wrapper.
Here is a table summarizing the two approaches: