<?xml version="1.0" encoding="UTF-8" ?>
<!--

  Licensed to the Apache Software Foundation (ASF) under one
  or more contributor license agreements.  See the NOTICE file
  distributed with this work for additional information
  regarding copyright ownership.  The ASF licenses this file
  to you 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.

-->

<project name="Test Groovyc Task" default="test1">

    <property name="srcPath" value="."/>
    <property name="destPath" value="${user.dir}/target/classes/groovy/test"/>

    <property name="javaVersion" value="7"/>

    <path id="groovyMaterials">
        <pathelement path="${java.class.path}"/>
    </path>

    <taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc" classpathref="groovyMaterials"/>

    <target name="GroovycTest1_NoFork_NoClasspath">
        <groovyc srcdir="${srcPath}" destdir="${destPath}" includes="GroovycTest1.groovy"/>
        <java classname="org.codehaus.groovy.ant.GroovycTest1"/>
    </target>

    <target name="GroovycTest1_NoFork_WithGroovyClasspath">
        <groovyc srcdir="${srcPath}" destdir="${destPath}" includes="GroovycTest1.groovy"
                 classpathref="groovyMaterials"/>
        <java classname="org.codehaus.groovy.ant.GroovycTest1"/>
    </target>

    <target name="GroovycTest1_NoFork_WithJavaClasspath">
        <groovyc srcdir="${srcPath}" destdir="${destPath}" includes="GroovycTest1.groovy"/>
        <java classname="org.codehaus.groovy.ant.GroovycTest1" classpathref="groovyMaterials"/>
    </target>

    <target name="GroovycTest1_NoFork_WithBothClasspath">
        <groovyc srcdir="${srcPath}" destdir="${destPath}" includes="GroovycTest1.groovy"
                 classpathref="groovyMaterials"/>
        <java classname="org.codehaus.groovy.ant.GroovycTest1" classpathref="groovyMaterials"/>
    </target>

    <target name="GroovycTest1_ForkGroovy_NoClasspath">
        <groovyc srcdir="${srcPath}" destdir="${destPath}" includes="GroovycTest1.groovy" fork="true"/>
        <java classname="org.codehaus.groovy.ant.GroovycTest1"/>
    </target>

    <target name="GroovycTest1_ForkGroovy_WithGroovyClasspath">
        <groovyc srcdir="${srcPath}" destdir="${destPath}" includes="GroovycTest1.groovy" classpathref="groovyMaterials"
                 fork="true"/>
        <java classname="org.codehaus.groovy.ant.GroovycTest1"/>
    </target>

    <target name="GroovycTest1_ForkGroovy_WithJavaClasspath">
        <groovyc srcdir="${srcPath}" destdir="${destPath}" includes="GroovycTest1.groovy" fork="true"/>
        <java classname="org.codehaus.groovy.ant.GroovycTest1" classpathref="groovyMaterials"/>
    </target>

    <target name="GroovycTest1_ForkGroovy_WithBothClasspath">
        <groovyc srcdir="${srcPath}" destdir="${destPath}" includes="GroovycTest1.groovy" classpathref="groovyMaterials"
                 fork="true"/>
        <java classname="org.codehaus.groovy.ant.GroovycTest1" classpathref="groovyMaterials"/>
    </target>

    <target name="GroovycTest1_Joint_NoFork_NoClasspath">
        <groovyc srcdir="${srcPath}" destdir="${destPath}" includes="GroovycTest1.groovy,GroovyTest2.java">
            <javac source="${javaVersion}" target="${javaVersion}" debug="true"/>
        </groovyc>
        <java classname="org.codehaus.groovy.ant.GroovycTest1"/>
        <java classname="org.codehaus.groovy.ant.GroovycTest2"/>
    </target>

    <target name="GroovycTest1_Joint_NoFork_WithGroovyClasspath">
        <groovyc srcdir="${srcPath}" destdir="${destPath}" includes="GroovycTest1.groovy,GroovycTest2.java"
                 classpathref="groovyMaterials">
            <javac source="${javaVersion}" target="${javaVersion}" debug="true"/>
        </groovyc>
        <java classname="org.codehaus.groovy.ant.GroovycTest1"/>
        <java classname="org.codehaus.groovy.ant.GroovycTest2"/>
    </target>

    <target name="Groovyc_Joint_NoFork_NestedCompilerArg_WithGroovyClasspath">
        <groovyc srcdir="${srcPath}" destdir="${destPath}" includes="IncorrectGenericsUsage.java"
                 classpathref="groovyMaterials">
            <javac source="${javaVersion}" target="${javaVersion}" debug="true">
                <compilerarg value="-Xlint"/>
            </javac>
        </groovyc>
    </target>

    <target name="GroovycTest1_Joint_NoFork_WithJavaClasspath">
        <groovyc srcdir="${srcPath}" destdir="${destPath}" includes="GroovycTest1.groovy,GroovycTest2.java">
            <javac source="${javaVersion}" target="${javaVersion}" debug="true"/>
        </groovyc>
        <java classname="org.codehaus.groovy.ant.GroovycTest1" classpathref="groovyMaterials"/>
        <java classname="org.codehaus.groovy.ant.GroovycTest2" classpathref="groovyMaterials"/>
    </target>

    <target name="GroovycTest1_Joint_NoFork_WithBothClasspath">
        <groovyc srcdir="${srcPath}" destdir="${destPath}" includes="GroovycTest1.groovy,GroovycTest2.java"
                 classpathref="groovyMaterials">
            <javac source="${javaVersion}" target="${javaVersion}" debug="true"/>
        </groovyc>
        <java classname="org.codehaus.groovy.ant.GroovycTest1" classpathref="groovyMaterials"/>
        <java classname="org.codehaus.groovy.ant.GroovycTest2" classpathref="groovyMaterials"/>
    </target>

    <target name="GroovycTest1_Joint_ForkGroovy_NoClasspath">
        <groovyc srcdir="${srcPath}" destdir="${destPath}" includes="GroovycTest1.groovy,GroovycTest2.java" fork="true">
            <javac source="${javaVersion}" target="${javaVersion}" debug="true"/>
        </groovyc>
        <java classname="org.codehaus.groovy.ant.GroovycTest1"/>
        <java classname="org.codehaus.groovy.ant.GroovycTest2"/>
    </target>

    <target name="GroovycTest1_Joint_ForkGroovy_WithGroovyClasspath">
        <groovyc srcdir="${srcPath}" destdir="${destPath}" includes="GroovycTest1.groovy,GroovycTest2.java" fork="true"
                 classpathref="groovyMaterials">
            <javac source="${javaVersion}" target="${javaVersion}" debug="true"/>
        </groovyc>
        <java classname="org.codehaus.groovy.ant.GroovycTest1"/>
        <java classname="org.codehaus.groovy.ant.GroovycTest2"/>
    </target>

    <target name="GroovycTest1_Joint_ForkGroovy_WithJavaClasspath">
        <groovyc srcdir="${srcPath}" destdir="${destPath}" includes="GroovycTest1.groovy,GroovycTest2.java" fork="true">
            <javac source="${javaVersion}" target="${javaVersion}" debug="true"/>
        </groovyc>
        <java classname="org.codehaus.groovy.ant.GroovycTest1" classpathref="groovyMaterials"/>
        <java classname="org.codehaus.groovy.ant.GroovycTest2" classpathref="groovyMaterials"/>
    </target>

    <target name="GroovycTest1_Joint_ForkGroovy_WithBothClasspath">
        <groovyc srcdir="${srcPath}" destdir="${destPath}" includes="GroovycTest1.groovy,GroovycTest2.java" fork="true"
                 classpathref="groovyMaterials">
            <javac source="${javaVersion}" target="${javaVersion}" debug="true"/>
        </groovyc>
        <java classname="org.codehaus.groovy.ant.GroovycTest1" classpathref="groovyMaterials"/>
        <java classname="org.codehaus.groovy.ant.GroovycTest2" classpathref="groovyMaterials"/>
    </target>

    <target name="GroovycTest1_ForkGroovy_NoClasspath_WithJavaHome">
        <groovyc srcdir="${srcPath}" destdir="${destPath}" includes="GroovycTest1.groovy" fork="true"
                 javahome="${alt.java.home}"/>
        <java classname="org.codehaus.groovy.ant.GroovycTest1"/>
    </target>

    <target name="GroovycTest1_ForkGroovy_WithGroovyClasspath_WithJavaHome">
        <groovyc srcdir="${srcPath}" destdir="${destPath}" includes="GroovycTest1.groovy" classpathref="groovyMaterials"
                 fork="true" javahome="${alt.java.home}"/>
        <java classname="org.codehaus.groovy.ant.GroovycTest1"/>
    </target>

    <target name="GroovycTest1_ForkGroovy_WithJavaClasspath_WithJavaHome">
        <groovyc srcdir="${srcPath}" destdir="${destPath}" includes="GroovycTest1.groovy" fork="true"
                 javahome="${alt.java.home}"/>
        <java classname="org.codehaus.groovy.ant.GroovycTest1" classpathref="groovyMaterials"/>
    </target>

    <target name="GroovycTest1_ForkGroovy_WithBothClasspath_WithJavaHome">
        <groovyc srcdir="${srcPath}" destdir="${destPath}" includes="GroovycTest1.groovy" classpathref="groovyMaterials"
                 fork="true" javahome="${alt.java.home}"/>
        <java classname="org.codehaus.groovy.ant.GroovycTest1" classpathref="groovyMaterials"/>
    </target>

    <target name="GroovycTest1_ForkGroovy_NoClasspath_Fail">
        <groovyc srcdir="${srcPath}" destdir="${destPath}" includes="GroovyTestBad1.groovy" fork="true"/>
        <java classname="org.codehaus.groovy.ant.GroovycTest1"/>
    </target>

    <target name="noForkNoAntRuntime">
        <groovyc srcdir="${srcPath}" destdir="${destPath}" includes="GroovycTest1.groovy" fork="false" includeAntRuntime="false"/>
    </target>

    <!-- GROOVY-9197 -->
    <target name="jointForkedCompilation_ExternalJarOnClasspath">
        <presetdef name="compile">
            <groovyc fork="true" includeantruntime="false">
                <javac debug="true" source="${javaVersion}" target="${javaVersion}"/>
            </groovyc>
        </presetdef>

        <path id="the.classpath">
            <path refid="groovyMaterials"/>
            <fileset file="commons-lang3-3.4.jar"/>
        </path>

        <compile srcdir="${srcPath}" destdir="${destPath}" includes="MakesExternalReference.java">
            <classpath refid="the.classpath"/>
        </compile>

        <java classname="org.codehaus.groovy.ant.MakesExternalReference" classpathref="the.classpath"/>
    </target>

    <target name="clean">
        <delete quiet="true">
            <fileset dir="${destPath}/org/codehaus/groovy/ant">
                <include name="GroovycTest1*.class"/>
                <include name="GroovycTest2*.class"/>
                <include name="IncorrectGenericsUsage.class"/>
                <include name="MakesExternalReference.class"/>
            </fileset>
        </delete>
    </target>

</project>
