白话解析如下:
===========
Mac 系统下载到 Gradle 压缩包后,解压到某一目录下,然后设置环境变量,命令如下:
vi ~/.profile
按 i 进行编辑模式,用方向键向下移动光标到末尾,并添加如下内容:
export GRADLE_HOME=/xxx/yyy/.../gradle-2.5 export PATH=$GRADLE_HOME/bin:$PATH
按 ESC 键退出编辑模式,输入 w 回车保存,再输入 q 回车退出 vi 编辑器。
接下来测试 gradle 是否可用,新开一个终端即命令行窗口,输入:
gradle -v
回车执行后,会出现如下内容,表示已成功安装可用:
------------------------------------------------------------ Gradle 2.5 ------------------------------------------------------------ Build time: 2015-07-08 07:38:37 UTC Build number: none Revision: 093765bccd3ee722ed5310583e5ed140688a8c2b Groovy: 2.3.10 Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013 JVM: 1.8.0_40 (Oracle Corporation 25.40-b25) OS: Mac OS X 10.10.4 x86_64
Chapter 4. Installing Gradle
4.1. Prerequisites
Gradle requires a Java JDK or JRE to be installed, version 6 or higher (to check, use java -version
). Gradle ships with its own Groovy library, therefore Groovy does not need to be installed. Any existing Groovy installation is ignored by Gradle.
Gradle uses whatever JDK it finds in your path. Alternatively, you can set the JAVA_HOME
environment variable to point to the installation directory of the desired JDK.
4.2. Download
You can download one of the Gradle distributions from the Gradle web site.
4.3. Unpacking
The Gradle distribution comes packaged as a ZIP. The full distribution contains:
- The Gradle binaries.
- The user guide (HTML and PDF).
- The DSL reference guide.
- The API documentation (Javadoc and Groovydoc).
- Extensive samples, including the examples referenced in the user guide, along with some complete and more complex builds you can use as a starting point for your own build.
- The binary sources. This is for reference only. If you want to build Gradle you need to download the source distribution or checkout the sources from the source repository. See theGradle web site for details.
4.4. Environment variables
For running Gradle, add
to your GRADLE_HOME
/binPATH
environment variable. Usually, this is sufficient to run Gradle.
4.5. Running and testing your installation
You run Gradle via the gradle command. To check if Gradle is properly installed just type gradle -v. The output shows the Gradle version and also the local environment configuration (Groovy, JVM version, OS, etc.). The displayed Gradle version should match the distribution you have downloaded.
4.6. JVM options
JVM options for running Gradle can be set via environment variables. You can use either GRADLE_OPTS
or JAVA_OPTS
, or both. JAVA_OPTS
is by convention an environment variable shared by many Java applications. A typical use case would be to set the HTTP proxy in JAVA_OPTS
and the memory options in GRADLE_OPTS
. Those variables can also be set at the beginning of thegradle or gradlew script.
Note that it‘s not currently possible to set JVM options for Gradle on the command line.
Chapter 3. Tutorials
3.1. Getting Started
The following tutorials introduce some of the basics of Gradle, to help you get started.
- Chapter 4, Installing Gradle
-
Describes how to install Gradle. - Chapter 6, Build Script Basics
-
Introduces the basic build script elements: projects and tasks. - Chapter 7, Java Quickstart
-
Shows how to start using Gradle‘s build-by-convention support for Java projects. - Chapter 8, Dependency Management Basics
-
Shows how to start using Gradle‘s dependency management. - Chapter 9, Groovy Quickstart
-
Using Gradle‘s build-by-convention support for Groovy projects. - Chapter 10, Web Application Quickstart
-
Using Gradle‘s build-by-convention support for Web applications.
The latest release of Gradle is version 2.5, released on 8th July 2015.
- Complete distribution (binaries, sources and offline documentation)
- Binary only distribution (no documentation or source code)
- Gradle source code (just the Gradle source code; not a usable Gradle installation)