| <?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="groovyCodeInExternalFileset" depends="defineTask"> |
| <groovy> |
| <fileset file="GroovyTest1.groovy"/> |
| <!-- skip over copyright header, just as an example --> |
| <filterchain> |
| <headfilter skip="18"/> |
| </filterchain> |
| </groovy> |
| </target> |
| |
| <target name="groovyCodeInExternalFileResource" depends="defineTask"> |
| <groovy> |
| <file file="GroovyTest1.groovy"/> |
| </groovy> |
| </target> |
| |
| <target name="groovyCodeInExternalJavaConstantResource" depends="defineTask"> |
| <groovy> |
| <javaconstant name="org.codehaus.groovy.ant.GroovyTest.CODE_FRAGMENT"/> |
| </groovy> |
| </target> |
| |
| <target name="groovyCodeInExternalURLResource" depends="defineTask"> |
| <groovy> |
| <url url="https://raw.githubusercontent.com/apache/groovy/master/subprojects/groovy-ant/src/test-resources/org/codehaus/groovy/ant/GroovyTest1.groovy"/> |
| </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="groovyErrorMsg_NonExistingFile" depends="defineTask"> |
| <groovy src="Does_not_exist.groovy"/> |
| </target> |
| |
| <target name="defineTask"> |
| <taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy"/> |
| </target> |
| </project> |