Installation Guide
Learn how to install and configure gradle on your system
Installing and configuring Gradle is a straightforward process once you understand the key steps and best practices. This guide walks you through the most common installation methods for Windows, macOS, and Linux, shows how to set up essential environment variables, and explains how to fine‑tune Gradle for faster, more reliable builds.
Prerequisites
- Java Development Kit (JDK): Gradle requires Java 8 or newer. Verify your installation with
java -version. - Environment variables:
JAVA_HOMEmust point to the JDK installation directory, and the JDK’sbindirectory should be on your systemPATH.
1. Installation Methods
| OS | Method | Commands | Notes |
|---|---|---|---|
| Windows | 1. Manual ZIP | 1. Download gradle-<version>-bin.zip from https://gradle.org/releases.2. Extract to C:\Gradle. 3. Add C:\Gradle\gradle-<version>\bin to the system PATH. |
Use setx to set environment variables permanently (requires a new shell). |
| 2. Chocolatey | choco install gradle |
Installs the latest stable version automatically. | |
| 3. SDKMAN (via WSL or Git Bash) | `curl -s "https://get.sdkman.io" | bash<br>sdk install gradle` |
|
| 4. Winget | winget install gradle |
Alternative Windows package manager. | |
| 5. Scoop | scoop install gradle |
Another Windows package manager. | |
| macOS | 1. Homebrew | brew install gradle |
Installs the latest stable release. |
| 2. Manual ZIP | Same as Windows, but extract to /opt/gradle. Add to PATH in .zshrc or .bash_profile. |
||
| 3. SDKMAN | `curl -s "https://get.sdkman.io" | bash<br>sdk install gradle` |
|
| Linux | 1. SDKMAN | `curl -s "https://get.sdkman.io" | bash<br>sdk install gradle` |
| 2. Manual ZIP | Extract to /opt/gradle. Add to PATH in /etc/profile.d/gradle.sh. |
||
| 3. Package managers | sudo apt-get install gradle (Debian/Ubuntu) – may provide an older version.sudo dnf install gradle (Fedora/RHEL)sudo snap install gradle |
Use SDKMAN for the latest. |
2. Verify the Installation
Run gradle -v (or gradle --version). The output should display the Gradle version, the JVM in use, and operating system details. If you see an error about missing Java, double‑check that JAVA_HOME is correctly set and that the JDK’s bin directory is on your PATH.
3. Configuring Gradle
| Configuration | How to Set | Typical Use |
|---|---|---|
Gradle User Home (GRADLE_USER_HOME) |
export GRADLE_USER_HOME=~/my-gradle |
Custom cache location. |
| Gradle Daemon | org.gradle.daemon=true in gradle.properties |
Improves build speed by reusing a JVM. |
| Parallel Execution | org.gradle.parallel=true |
Enables parallel task execution. |
| Maximum Worker Count | org.gradle.workers.max=4 |
Limits CPU usage. |
| Build Cache | org.gradle.caching=true |
Reuses outputs across builds. |
| Logging | org.gradle.logging.level=info |
Controls verbosity. |
| Wrapper | ./gradlew wrapper --gradle-version <ver> |
Generates gradlew scripts for a project‑specific Gradle version. |
Add these settings to a gradle.properties file in your project root or in the Gradle user home directory (~/.gradle/gradle.properties) to apply them globally.
4. Using the Gradle Wrapper
The wrapper is a small script that downloads the exact Gradle version your project requires. To generate it, run:
gradle wrapper
or, if you already have a wrapper, use:
./gradlew wrapper
Commit the generated gradlew, gradlew.bat, and the gradle/wrapper/gradle-wrapper.properties file to version control. Team members can then build with:
- Unix/macOS:
./gradlew build - Windows:
gradlew.bat build
This eliminates the need for a global Gradle installation and guarantees consistent builds across environments.
5. Common Issues & Troubleshooting
| Issue | Symptom | Fix |
|---|---|---|
| JAVA_HOME not set | “Could not find java home” | Set JAVA_HOME to the JDK root and add $JAVA_HOME/bin to PATH. |
| Permission errors on Linux/macOS | “Permission denied” when running gradle |
Make the binary executable: chmod +x gradle. |
| Proxy settings | Gradle fails to download dependencies | Add systemProp.http.proxyHost, systemProp.http.proxyPort, etc., to gradle.properties. |
| Outdated Gradle | Build fails due to deprecated APIs | Use SDKMAN or the wrapper to upgrade to a newer version. |
6. Best Practices
- Use the Wrapper – Keeps the Gradle version consistent across all developers and CI environments.
- Centralize Settings – Store project‑wide properties in
gradle.properties. - Enable Daemon & Parallelism – Improves build times, especially for large multi‑module projects.
- Clean the Cache Regularly – Run
gradle cleanBuildCacheto free disk space and avoid stale artifacts. - Keep Gradle Updated – Use SDKMAN or the wrapper to stay on the latest stable release.
7. Further Reading
- Official Gradle User Manual – Installation guide.
- Gradle Blog posts on installation tips.
- StackOverflow threads on common installation pitfalls.
These resources provide deeper dives into advanced configuration, troubleshooting, and performance tuning.