<!--
  ~ Copyright 2010 the original author or authors.
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<chapter id="installation">
<title>Installing Gradle</title>

<section>
    <title>Prerequisites</title>

    <para>Gradle requires a Java JDK to be installed. Gradle ships with its own Groovy library, therefore no Groovy
        needs to be installed. Any existing Groovy installation is ignored by Gradle. The standard Gradle distribution
        requires a JDK 1.5 or higher. We also provide a distinct JDK 1.4 compatible distribution.
    </para>

    <para>Gradle uses whichever JDK it finds in your path (to check, use <userinput>java -version</userinput>).
        Alternatively, you can set the <envar>JAVA_HOME</envar> environment variable to point to the install directory
        of the desired JDK.
    </para>
</section>

<section>
    <title>Download</title>
    <para>You can download one of the Gradle distributions from the <ulink url="website:downloads.html">Gradle web site</ulink>.</para>
</section>

<section>
<title>Unpacking</title>

<para>The Gradle distribution comes packaged as a ZIP. The full distribution contains:</para>

<itemizedlist>
    <listitem><para>The Gradle binaries.</para></listitem>
    <listitem><para>The user guide (HTML and PDF).</para></listitem>
    <listitem><para>The API documentation (Javadoc and Groovydoc).</para></listitem>
    <listitem>
        <para>Extensive samples, including the examples referenced in the user guide, along with some complete and more
            complex builds you can use the starting point for your own build.
        </para>
    </listitem>
    <listitem>
        <para>The binary sources (If you want to build Gradle you need to download the source distribution or checkout
            the sources from the source repository).
        </para>
    </listitem>
</itemizedlist>

<note>
<title>For Un*x users</title>

<para>You need a GNU compatible tool to unzip Gradle, if you want the file permissions to be properly set. We mention this as
some zip front ends for Mac OS X don't restore the file permissions properly.
</para>
</note>
</section>

<section>
<title>Environment variables</title>

<para>For running Gradle, add <filename><replaceable>GRADLE_HOME</replaceable>/bin</filename> to your <envar>PATH</envar>
    environment variable. Usually, this is sufficient to run Gradle. Optionally, you may also want to set the
    <envar>GRADLE_HOME</envar> environment variable to point to the root directory of your Gradle installation.
</para>
</section>

<section>
<title>Running and testing your installation</title>

<para>You run Gradle via the <command>gradle</command> command. To check if Gradle is properly installed just type
<command>gradle -v</command> and you should get an output like:
</para>

<screen>
------------------------------------------------------------
Gradle 0.9-rc-1
------------------------------------------------------------

Gradle buildtime: Tuesday, 3 August 2010 6:59:23 PM EST
Groovy: 1.7.3
Ant: Apache Ant version 1.8.1 compiled on April 30 2010
Ivy: 2.2.0-rc1
Java: 1.6.0_20
JVM: 16.3-b01
JVM Vendor: Sun Microsystems Inc.
OS Name: Linux
</screen>

</section>

<section>
<title>JVM options</title>

<para>JVM options for running Gradle can be set via environment variables. You can use <envar>GRADLE_OPTS</envar>
or <envar>JAVA_OPTS</envar>. Those variables can be used together. <envar>JAVA_OPTS</envar> is by convention an environment
variable shared by many Java applications. A typical use case would be to set the HTTP proxy in <envar>JAVA_OPTS</envar>
and the memory options in <envar>GRADLE_OPTS</envar>. Those variables can also be set at the beginning
of the <command>gradle</command> or <command>gradlew</command> script.
</para>

</section>

<section condition="standalone">
<title>Getting help</title>

<para>You might check the user guide at <filename><replaceable>GRADLE_HOME</replaceable>/docs/userguide/userguide.html</filename>.
It is also available on the <ulink url="website:userguide.html">Gradle web site</ulink>.
Typing <command>gradle -h</command> prints the command line help. Typing <command>gradle -t</command> shows all the
tasks of a Gradle build.
</para>

</section>

</chapter>
