---
title: "Gradle Installation"
author: "IXHONG"
date: "2018-01-05T10:26:40Z"
tags: []
categories: ["编程语言"]
slug: "gradle-installation"
draft: false
lastmod: "2018-01-05T10:26:40Z"
id: 2406736
url: "https://wely.iteye.com/blog/2406736"
---

# Installation

- [Helpful Information](https://gradle.org/install/#helpful-information)
- [Install](https://gradle.org/install/#install)
  
  - [Install with a package manager](https://gradle.org/install/#with-a-package-manager)
  - [Install manually](https://gradle.org/install/#manually)
- [Upgrade with the Gradle Wrapper](https://gradle.org/install/#with-the-gradle-wrapper)
- [Older Releases](https://gradle.org/install/#older-releases)

## Helpful Information

- You can sign up for [free live training](https://gradle.org/training) with a Gradle core engineer bi-monthly
- Our [guides](https://gradle.org/guides) and [reference documentation](https://docs.gradle.org/current/userguide/userguide.html) make good reading materials
- You can visualize and debug your build with [build scans](https://gradle.com/scans/get-started)
- The [Gradle Newsletter](https://newsletter.gradle.com/) is a great way to keep up-to-date with issues crafted monthly
- [Command-line completion](https://git.io/gradle-completion) scripts are available for bash and zsh

Gradle runs on all major operating systems and requires only a [Java JDK or JRE](http://www.oracle.com/technetwork/java/javase/downloads/index.html) version 7 or higher to be installed. To check, run `java -version`:

```
$ java -version
java version "1.8.0_121"
```

## Install

### Install with a package manager

[SDKMAN!](http://sdkman.io/) is a tool for managing parallel versions of multiple Software Development Kits on most Unix-based systems.

```
$ sdk install gradle 4.4.1
```

[Homebrew](http://brew.sh/) is “the missing package manager for macOS”.

```
$ brew install gradle
```

[Scoop](http://scoop.sh/) is a command-line installer for Windows inspired by Homebrew.

```
$ scoop install gradle
```

[Chocolatey](https://chocolatey.org/) is “the package manager for Windows”.

```
$ choco install gradle
```

[MacPorts](https://www.macports.org/) is a system for managing tools on macOS:

```
$ sudo port install gradle
```

#### [› Proceed to next steps](https://gradle.org/install/#helpful-information)

### Install manually

#### Step 1. [Download](https://gradle.org/releases) the latest Gradle distribution

The current Gradle release is version 4.4.1, released on 20 Dec 2017. The distribution zip file comes in two flavors:

- [Binary-only](https://services.gradle.org/distributions/gradle-4.4.1-bin.zip) ([sha256](https://services.gradle.org/distributions/gradle-4.4.1-bin.zip.sha256))
- [Complete](https://services.gradle.org/distributions/gradle-4.4.1-all.zip), with docs and sources ([sha256](https://services.gradle.org/distributions/gradle-4.4.1-all.zip.sha256))

If in doubt, choose the binary-only version and browse [docs](https://docs.gradle.org/current) and [sources](https://github.com/gradle/gradle) online.

Need to work with an older version? See the [releases page](https://gradle.org/releases).

#### Step 2. Unpack the distribution

##### Linux & MacOS users

Unzip the distribution zip file in the directory of your choosing, e.g.:

```
$ mkdir /opt/gradle
$ unzip -d /opt/gradle gradle-4.4.1-bin.zip
$ ls /opt/gradle/gradle-4.4.1
LICENSE  NOTICE  bin  getting-started.html  init.d  lib  media
```

##### Microsoft Windows users

Create a new directory `C:\Gradle` with **File Explorer**.

Open a second **File Explorer** window and go to the directory where the Gradle distribution was downloaded. Double-click the ZIP archive to expose the content. Drag the content folder `gradle-4.4.1` to your newly created `C:\Gradle` folder.

Alternatively you can unpack the Gradle distribution ZIP into `C:\Gradle` using an archiver tool of your choice.

#### Step 3. Configure your system environment

##### Linux & MacOS users

Configure your `PATH` environment variable to include the `bin` directory of the unzipped distribution, e.g.:

```
 $ export PATH=$PATH:/opt/gradle/gradle-4.4.1/bin
```

##### Microsoft Windows users

In **File Explorer** right-click on the `This PC` (or `Computer`) icon, then click `Properties` -&gt; `Advanced System Settings` -&gt; `Environmental Variables`.

Under `System Variables` select `Path`, then click `Edit`. Add an entry for `C:\Gradle\gradle-4.4.1\bin`. Click OK to save.

#### Step 4. Verify your installation

Open a console (or a Windows command prompt) and run `gradle -v` to run gradle and display the version, e.g.:

```
$ gradle -v

------------------------------------------------------------
Gradle 4.4.1
------------------------------------------------------------
```

#### [› Proceed to next steps](https://gradle.org/install/#helpful-information)

## Upgrade with the Gradle Wrapper

If your existing Gradle-based build uses the [Gradle Wrapper](https://docs.gradle.org/4.4.1/userguide/gradle_wrapper.html), you can easily upgrade by running the `wrapper` task, specifying the desired Gradle version:

```
$ ./gradlew wrapper --gradle-version=4.4.1 --distribution-type=bin
```

Note that it is not necessary for Gradle to be installed to use the Gradle wrapper. The next invocation of `gradlew` or `gradlew.bat` will download and cache the specified version of Gradle.

```
$ ./gradlew tasks
Downloading https://services.gradle.org/distributions/gradle-4.4.1-bin.zip
...
```

#### [› Proceed to next steps](https://gradle.org/install/#helpful-information)

## Older Releases

You can find all releases and their checksums on the [releases page](https://gradle.org/releases).