<?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="hudson" basedir="."
    xmlns:as="antlib:org.codehaus.mojo.animal_sniffer" >

    <target name="verify" depends="river-runtime,verify-15-sun"
                                description="River-verify entry">
    </target>

    <target name="river-trunk" description="River-trunk entry">
        <ant>
            <target name="hudson-ci" />
        </ant>
    </target>

    <typedef uri="antlib:org.codehaus.mojo.animal_sniffer">
        <classpath>
            <fileset dir="dep-libs/animal-sniffer">
                <include name="**/*.jar"/>
            </fileset>
            <fileset dir="dep-libs/asm">
                <include name="**/*.jar"/>
            </fileset>
        </classpath>
    </typedef>

    <target name="river-runtime" >
        <ant>
            <target name="clean" />
            <target name="river-runtime" />
        </ant>
    </target>

    <macrodef name="verify-signature">
        <attribute name="signature" />
        <sequential>
            <as:check-signature signature="@{signature}" >
                <path path="dep-libs/asm/asm-tree-3.2.jar" />
                <path path="lib" />
                <path path="lib-dl" />
                <ignore className="org.apache.velocity.app.VelocityEngine"/>
                <ignore className="org.apache.velocity.VelocityContext"/>
                <ignore className="org.apache.velocity.Template"/>
            </as:check-signature>
        </sequential>
    </macrodef>

    <target name="verify-14" >
        <verify-signature signature="dep-libs/animal-sniffer/java14-1.0.signature" />
    </target>

    <target name="verify-14-sun" >
        <verify-signature signature="dep-libs/animal-sniffer/java14-sun-1.0.signature" />
    </target>

    <target name="verify-15" >
        <verify-signature signature="dep-libs/animal-sniffer/java15-1.0.signature" />
    </target>

    <target name="verify-15-sun" >
        <verify-signature signature="dep-libs/animal-sniffer/java15-sun-1.0.signature" />
    </target>

    <target name="verify-15-ibm" >
        <verify-signature signature="dep-libs/animal-sniffer/java15-ibm-1.0.signature" />
    </target>

    <target name="qa-tree" depends="qa-tree-build, qa-tree-zip" description="build QA tree" >
    </target>
    
    <target name="qa-tree-build" description="build QA tree" >
        <ant dir="qa" inheritall="false">
            <target name="clean" />
            <target name="harness-runtime" />
        </ant>
    </target>

    <target name="qa-tree-zip" description="Zip QA tree" >
        <property name="qa-tree-zipfile" value="build/qa-tree.zip" />
        <delete file="${qa-tree-zipfile}" />
        <zip destfile="${qa-tree-zipfile}" >
            <fileset dir=".">
                <exclude name="examples/**" />
                <exclude name="netbeans/**" />
                <exclude name="poms/**" />
                <exclude name="qa/doc/**" />
                <exclude name="qa-matrix/**" />
                <exclude name="src-doc/**" />
                <!--
                <exclude name="build/**" />
                -->
            </fileset>
        </zip>
    </target>
    
    <target name="run-qa" description="execute QA test" >
        <property name="harness-runtime-src" value="https://builds.apache.org/view/M-R/view/River/job/River-QA-runtime/lastSuccessfulBuild/artifact/jtsk/trunk/harness-runtime.jar" />
        <property name="harness-runtime-dst" value="harness-runtime.jar" />
        
        <get src="${harness-runtime-src}" dest="${harness-runtime-dst}" />
        <unzip src="${harness-runtime-dst}" dest="." />
        <ant dir="qa" target="run-categories" inheritall="false">
            <property name="run.categories" value="id,loader,policyprovider,locatordiscovery,activation,config,discoverymanager,joinmanager,url,iiop,jrmp,reliability,thread,renewalmanager,constraint,export,lookupdiscovery,servicediscovery,io,security,lookupservice,renewalservice,eventmailbox,jeri,start,discoveryservice,discoveryproviders,javaspace,txnmanager"/>
        </ant>
    </target>

    <target name="list-tests" >
        <fileset id="qa-td-files" dir="qa/src/">
            <include name="**/*.td" />
        </fileset>
        <script language="javascript"> 
        <![CDATA[
            var testfiles = project.getReference("qa-td-files")
//            println( testfiles )
//            println( testfiles.getClass() )
            var iter = testfiles.iterator();
            while( iter.hasNext() ) {
//                println("-----")
                println(iter.next().getName().replace("/","-"))
            }
        ]]> 
        </script>
    </target>

</project>
