<!--
  ~ 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 or JRE to be installed. Gradle requires a Java version 6 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">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:development">Gradle web site</ulink> for details.
        </para>
    </listitem>
</itemizedlist>
</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.
</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>. The output shows Gradle version and also local environment configuration (groovy and JVM version, etc.).
    The displayed Gradle version should match the distribution you have downloaded.
</para>

</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>
