<!--
  ~ 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 requires a JDK 1.5 or higher. Gradle ships with its own
        Groovy library, therefore no Groovy needs to be installed. Any existing Groovy installation is ignored by Gradle.
    </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 DSL reference guide.</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. 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 the <ulink url="website:build.html">Gradle web site</ulink> for details).
        </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.1
------------------------------------------------------------

Gradle build time: Sunday, 2 January 2011 09:52:16 AM EST
Groovy: 1.7.6
Ant: Apache Ant version 1.8.1 compiled on April 30 2010
Ivy: 2.2.0
JVM: 1.6.0_22 (Sun Microsystems Inc. 17.1-b03)
OS: Linux 2.6.35-23-generic amd64
</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:documentation.html">Gradle web site</ulink>.
Typing <command>gradle help</command> prints the command line help. Typing <command>gradle tasks</command> shows all the
tasks of a Gradle build.
</para>

</section>

</chapter>
