view groovy-ant.xml @ 123:6f1918544f7f

Add test to cleanLocal to ensure local repo was removed
author smith@nwoca.org
date Wed, 06 Feb 2013 19:58:34 +0000
parents 9dcb429eea14
children
line wrap: on
line source
<?xml version="1.0" encoding="UTF-8"?>
<project name="groovy-project-tasks" default="all" basedir="."
        xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3"
        xmlns:ssdtant="antlib:org.ssdt_ohio.tools.ant">
 
    <description>Ant tasks shared by Groovy based NetBeans projects.</description>

    <!-- Following targets  need to be copied to the build.xml. 
    <target name="-javadoc-build"       depends="groovydoc"/>
    <target name="-init-macrodef-junit" depends="-init-macrodef-junit-groovy"/>
    <target name="-pre-compile"         depends="-groovy-init-macrodef-javac-groovyc"/>
    <target name="-do-test-run"         depends="init,compile-test,-pre-test-run,-groovy-do-test-run" if="have.tests" />
    end copy -->

<!--    <ssdtant:replace-target target="javadoc-build" with="groovydoc"/>-->
    <ssdtant:replace-target target="-javadoc-build" with="groovydoc"/>
    <ssdtant:replace-target target="-init-macrodef-junit" with="-init-macrodef-junit-groovy"/>
    <ssdtant:replace-target target="-do-test-run" with="-groovy-do-test-run"/>
    <ssdtant:replace-target target="-init-macrodef-javac" with="-groovy-init-macrodef-javac-groovyc"/>

    <target depends="init" name="groovydoc">
        <taskdef name="groovydoc"
                 classname="org.codehaus.groovy.ant.Groovydoc"
                 classpath="${run.classpath}"/>
        <mkdir dir="${dist.javadoc.dir}"/>
        <groovydoc 
            destdir="${dist.javadoc.dir}"
            sourcepath="${src.dir}"
            windowtitle="${javadoc.windowtitle}"
            use="${javadoc.use}"
            private="${javadoc.private}"
            author="${javadoc.author}"
            doctitle="${javadoc.windowtitle}" >           
            <link packages="java.,org.xml.,javax.,org.xml." href="http://download.oracle.com/javase/6/docs/api/"/>
            <link packages="org.apache.ant.,org.apache.tools.ant." href="http://www.dpml.net/api/ant/1.7.0"/>
            <link packages="org.junit.,junit.framework." href="http://junit.sourceforge.net/junit3.8.1/javadoc/"/>
            <link packages="groovy.,org.codehaus.groovy." href="http://groovy.codehaus.org/api/"/>
        </groovydoc>
    </target>

    <target name="-init-macrodef-junit-groovy">
        <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
            <attribute default="${includes}" name="includes"/>
            <attribute default="${excludes}" name="excludes"/>
            <attribute default="**" name="testincludes"/>
            <sequential>
                <property name="work.dir" value="${basedir}"/>
                <property name="jacoco.coverage.agent" value=""/>
                <property name="run.jvmargs" value=""/>
                <property name="j2ee.platform.classpath" value=""/>                
                <if>
                    <isset property="java.agent.jar"/>
                    <then>
                        <property name="jvm.agent" value="-javaagent:${java.agent.jar}"/>
                    </then>
                    <else>
                        <property name="jvm.agent" value=""/>
                    </else>
                </if>
                <propertyregex input="@{includes}" property="testg.includes" regexp="\.groovy" replace=".class" defaultValue="@{includes}"/>
                <junit  dir="${work.dir}"
                        errorproperty="tests.failed"
                        failureproperty="tests.failed"
                        fork="true"
                        forkmode="once"
                        showoutput="true">
                    <batchtest todir="${build.test.results.dir}">
                        <fileset dir="${build.test.classes.dir}" excludes="@{excludes},${excludes}" includes="${testg.includes}">
                            <filename name="@{testincludes}"/>
                        </fileset>
                    </batchtest>
                    <classpath>
                        <path path="${run.test.classpath}:${j2ee.platform.classpath}"/>
                    </classpath>
                    <syspropertyset>
                        <propertyref prefix="test-sys-prop."/>
                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
                    </syspropertyset>
                    <formatter type="brief" usefile="false"/>
                    <formatter type="xml"/>
                    <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
                    <jvmarg line="${run.jvmargs}"/>
                    <jvmarg line="${jvm.agent}"/>
                </junit>
            </sequential>
        </macrodef>
    </target>

    <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-groovy-do-test-run">
        <property name="groovy.test.includes" value="**/*Test.*"/>
        <j2seproject3:junit testincludes="${groovy.test.includes}"/>
    </target>

    <target name="-groovy-init-macrodef-javac-groovyc">
        <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
            <attribute name="srcdir" default="${src.dir}"/>
            <attribute name="destdir" default="${build.classes.dir}"/>
            <attribute name="classpath" default="${javac.classpath}"/>
            <attribute name="includes" default="${includes}"/>
            <attribute name="excludes" default="${excludes}"/>
            <attribute name="debug" default="${javac.debug}"/>
            <attribute name="sourcepath" default="${empty.dir}"/>
            <attribute name="gensrcdir" default="${empty.dir}"/>
            <attribute default="" name="processorpath"/>
            <attribute default="" name="apgeneratedsrcdir"/>
            <element name="customize" optional="true"/>
            <sequential>
                <echo message="using groovyc joint compiler (jse)"/>
                <taskdef name="groovyc" classpath="${javac.classpath}" classname="org.codehaus.groovy.ant.Groovyc"/>
                <property name="empty.dir" location="${build.dir}/empty"/>
                <mkdir dir="${empty.dir}"/>
                <groovyc fork="true" srcdir="@{srcdir}" sourcepath="@{sourcepath}" destdir="@{destdir}" encoding="${source.encoding}" includes="@{includes}" excludes="@{excludes}" includeAntRuntime="false">
                    <src>
                        <dirset dir="@{gensrcdir}" erroronmissingdir="false">
                            <include name="*"/>
                        </dirset>
                    </src>
                    <classpath>
                        <path path="@{classpath}"/>
                    </classpath>
                    <javac debug="@{debug}" deprecation="${javac.deprecation}" encoding="${source.encoding}" source="${javac.source}" target="${javac.target}">
                        <compilerarg line="${javac.compilerargs} ${javac.compilerargs.jaxws}"/>
                        <customize/>
                    </javac>
                </groovyc>
            </sequential>
        </macrodef>
        
        <macrodef name="javac" uri="http://www.netbeans.org/ns/web-project/2">
            <attribute default="${src.dir}" name="srcdir"/>
            <attribute default="${build.classes.dir}" name="destdir"/>
            <attribute default="${javac.classpath}:${j2ee.platform.classpath}" name="classpath"/>
            <attribute default="${javac.processorpath}" name="processorpath"/>
            <attribute default="${build.generated.sources.dir}/ap-source-output" name="apgeneratedsrcdir"/>
            <attribute default="${includes}" name="includes"/>
            <attribute default="${excludes}" name="excludes"/>
            <attribute default="${javac.debug}" name="debug"/>
            <attribute default="${empty.dir}" name="gensrcdir"/>
            <element name="customize" optional="true"/>
            <sequential>
                <echo message="using groovyc joint compiler (web)"/>
                <taskdef name="groovyc" classpath="${javac.classpath}" classname="org.codehaus.groovy.ant.Groovyc"/>
                <property location="${build.dir}/empty" name="empty.dir"/>
                <mkdir dir="${empty.dir}"/>
                <groovyc fork="true" srcdir="@{srcdir}" sourcepath="@{sourcepath}" destdir="@{destdir}" encoding="${source.encoding}" includes="@{includes}" excludes="@{excludes}" includeAntRuntime="false">
                    <src>
                        <dirset dir="@{gensrcdir}" erroronmissingdir="false">
                            <include name="*"/>
                        </dirset>
                    </src>
                    <classpath>
                        <path path="@{classpath}"/>
                    </classpath>
                    <javac debug="@{debug}" deprecation="${javac.deprecation}" encoding="${source.encoding}" source="${javac.source}" target="${javac.target}">
                        <compilerarg line="${javac.compilerargs} ${javac.compilerargs.jaxws}"/>
                        <customize/>
                    </javac>
                </groovyc>
                         
            </sequential>
        </macrodef>
        
        
        
    </target>
</project>