官术网_书友最值得收藏!

Installation and quick start

Gradle installation is quite simple. You can download the Gradle distribution from the Gradle home page at https://www.gradle.org/downloads, which is available in different formats.

Pre-requisites

Gradle requires a Java JDK or JRE to be installed, needing version 6 or higher (to check the Java version on your machine, use java -version). Some of the features might not work with JRE, so it is recommended to have JDK installed. Also, Gradle ships with its own Groovy library; therefore, Groovy does not need to be installed. Any existing Groovy installation is ignored by Gradle.

Gradle is available in three formats:

  • gradle-[version]-all.zip: This contains the source code, the binaries, and the documentation
  • gradle-[version]-bin.zip: This contains the binaries only
  • gradle-[version]-src.zip: This contains the source code only, in case you want to extend the Gradle features

Alternatively, you can just download gradle-[version]-bin.zip file.

Once downloaded, you need to unpack the zip file and configure it as per your operating system.

Gradle for Windows

Following are the steps for installing Gradle on Windows:

  1. Unpack the Gradle distribution on the hard drive.
  2. Add Gradle's installed path (for example, c:\gradle-2.4) to the GRADLE_HOME variable. Note that this location should be the parent directory of the bin or the lib folder.
  3. Add the GRADLE_HOME/bin to the PATH variable.

When you are ready to go ahead with Gradle, verify your installation by running the gradle command with the --version or -v command-line parameter.

> gradle –version

------------------------------------------------------------
Gradle 2.4
------------------------------------------------------------
 
Build time: 2015-05-05 08:09:24 UTC
Build number: none
Revision: 5c9c3bc20ca1c281ac7972643f1e2d190f2c943c
 
Groovy: 2.3.10
Ant: Apache Ant(TM) version 1.9.4 compiled on April 29 2014
JVM: 1.7.0_79 (Oracle Corporation 24.79-b02)
OS: Windows 8.1 6.3 amd64

Gradle for Mac/Linux

Following are the steps to install Gradle on the Mac/Linux operating system.

  1. Unpack the Gradle distribution.
  2. Add the following two lines in your initialization script (~/.profile).
  3. Export GRADLE_HOME = <Gradle_Installation_Dir>
  4. Export PATH=$PATH:$GRADLE_HOME/bin

Reload the profile by executing source ~/.profile and execute the gradle –version command. You will be able to see a similar output as mentioned in the previous section.

The Gradle JVM option

Gradle shares the same JVM options set by the environment variable JAVA_OPTS. If you don't want to use this setting and want to pass arguments specifically to the Gradle runtime, you can use the environment variable GRADLE_OPTS.

Suppose if JAVA_OPTS=512MB in your system and you want to increase the default maximum heap size to 1024MB for Gradle application. You can set it like this:

GRADLE_OPTS="-Xmx1024m"

We can apply this setting in the project-specific build file. Alternatively, we can also apply this setting to all of the Gradle build by adding the variable to the Gradle startup script (this will be discussed later in this chapter).

主站蜘蛛池模板: 嘉峪关市| 孟津县| 城固县| 扶绥县| 竹溪县| 额敏县| 横峰县| 额敏县| 乐安县| 呼玛县| 铁岭市| 凤冈县| 宜兴市| 兰州市| 固阳县| 岱山县| 娱乐| 金川县| 双鸭山市| 托克逊县| 噶尔县| 瓦房店市| 平遥县| 德格县| 珲春市| 黎城县| 桐乡市| 云梦县| 丰台区| 华阴市| 汉寿县| 卢氏县| 恭城| 云霄县| 鹤峰县| 尤溪县| 渑池县| 靖西县| 奉化市| 栾城县| 黑山县|