<?xml version="1.0" encoding="ISO-8859-1" ?>
<!--

  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-groovy-task" default="groovyCodeWithinTask" basedir=".">

    <target name="groovyCodeWithinTask" depends="defineTask">
        <groovy>
            org.codehaus.groovy.ant.GroovyTest.FLAG = "from groovy inlined in ant"
        </groovy>
    </target>

    <target name="groovyAntPropertyWithoutFork" depends="defineTask">
        <property name="someProp" value="someValue"/>
        <groovy>
            org.codehaus.groovy.ant.GroovyTest.FLAG = "someProp was " + project.properties.someProp
        </groovy>
    </target>

    <target name="groovyCodeInExternalFile" depends="defineTask">
        <groovy src="GroovyTest1.groovy"/>
    </target>

    <target name="groovyCodeInExternalFileWithOtherClass" depends="defineTask">
        <groovy src="GroovyTest2.groovy"/>
    </target>

    <target name="groovyClasspath_missing" depends="defineTask" description="should fail!">
        <groovy>
            def foo = new GroovyTest3Class()
            foo.doSomething()
        </groovy>
    </target>

    <target name="groovyClasspath_classpathAttribute" depends="defineTask">
        <groovy classpath="groovytest3">
            def foo = new GroovyTest3Class()
            foo.doSomething()
        </groovy>
    </target>

    <target name="groovyClasspath_classpathrefAttribute" depends="defineTask">
        <path id="myClasspathRef">
            <pathelement location="groovytest3"/>
        </path>

        <groovy classpathref="myClasspathRef">
            def foo = new GroovyTest3Class()
            foo.doSomething()
        </groovy>
    </target>

    <target name="groovyClasspath_nestedClasspath" depends="defineTask">
        <groovy>
            <classpath>
                <pathelement location="groovytest3"/>
            </classpath>
            def foo = new GroovyTest3Class()
            foo.doSomething()
        </groovy>
    </target>

    <target name="groovyArgUsage" depends="defineTask">
        <groovy classpath="groovytest3">
            <arg line="1 2 3"/>
            def foo = new GroovyTest3Class()
            foo.doSomethingWithArgs(args)
        </groovy>
    </target>

    <target name="groovyErrorMsg" depends="defineTask">
        <groovy>
            // should produce an error message
            def f = {
                t.notExisting()
            }
            f()
        </groovy>
    </target>

    <target name="groovyErrorMsg_ExternalFile" depends="defineTask">
        <groovy src="GroovyTest_errorMessage.groovy"/>
    </target>

    <target name="defineTask">
        <taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy"/>
    </target>
</project>