home | career | drupal | java | mac | mysql | perl | scala | uml | unix

Groovy example source code file (GroovyTest.xml)

This example Groovy source code file (GroovyTest.xml) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Groovy tags/keywords

groovytest3class, groovytest3class, iso-8859-1, iso-8859-1

The Groovy GroovyTest.xml source code

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

<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="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>

Other Groovy examples (source code examples)

Here is a short list of links related to this Groovy GroovyTest.xml source code file:

new blog posts

 

Copyright 1998-2014 Alvin Alexander, alvinalexander.com
All Rights Reserved.