<!--
  ~ Copyright 2009 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.
  -->
<appendix id='potential_traps' xmlns:xi="http://www.w3.org/2001/XInclude">
    <title>Potential Traps</title>
    <section id='sec:groovy_script_variables'>
        <title>Groovy script variables</title>
        <para>For Gradle users it is important to understand how Groovy deals with script variables. Groovy has two types
            of script variables. One with a local scope and one with a script wide scope.
        </para>
        <sample id="scope" dir="userguide/tutorial" title="Variables scope: local and script wide">
            <sourcefile file="scope.groovy"/>
            <output args=""/>
        </sample>
        <para>Variables which are declared with a type modifier are visible within closures but not visible within
            methods. This is a heavily discussed behavior in the Groovy community.
            <footnote>
                <para>One of those discussions can be found here:
                    <ulink url='http://www.nabble.com/script-scoping-question-td16034724.html'/>
                </para>
            </footnote>
        </para>
    </section>
    <section id='sec:configuration_and_execution_phase'>
        <title>Configuration and execution phase</title>
        <para>It is important to keep in mind that Gradle has a distinct configuration and execution phase (see 
            <xref linkend='build_lifecycle'/>).
        </para>
        <sample id="mkdirTrap" dir="userguide/tutorial/mkdirTrap" title="Distinct configuration and execution phase">
            <sourcefile file="build.gradle"/>
            <output args="-q compile"/>
        </sample>
        <para>As the creation of the directory happens during the configuration phase, the
            <literal>clean</literal>
            task removes the directory during the execution phase.
        </para>
    </section>
</appendix>
