<?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="river-qa-matrix" basedir="." default="default-prod" >

    <target name="default-prod" depends="init-prod, qa-tree, qa-run-test, clean">
    </target>
    
    <target name="default-prod-12" depends="init-dev-test, qa-run-test">
    </target>
    
    <target name="default-dev-cat" depends="init-dev-cat, qa-tree, qa-run-category">
    </target>
    
    <target name="default-dev-test" depends="init-dev-test, qa-tree, qa-run-test">
    </target>
    
    <target name="init-prod" >
        <echoproperties/>
    </target>
    
    <target name="init-dev-cat" >
        <property name="harness-runtime-src" value="file:${basedir}/../build/qa-tree.zip" />
        <property name="category" value="id" />
        <echoproperties/>
    </target>
    
    <target name="init-dev-test" >
        <property name="harness-runtime-src" value="file:${basedir}/../build/qa-tree.zip" />
        <property name="test" value="com-sun-jini-test-spec-url-httpmd-handler-SameFile.td" />
        <echoproperties/>
    </target>
    
    <target name="qa-tree" >
        <property name="harness-runtime-dst" value="tmp/qa-tree.zip" />
        <property name="harness-runtime-src" value="https://builds.apache.org/job/River-QA-tree/lastSuccessfulBuild/artifact/jtsk/trunk/build/qa-tree.zip" />

        <delete dir="tmp" />
        <mkdir dir="tmp" />
        <get src="${harness-runtime-src}" dest="${harness-runtime-dst}" />
        
        <delete dir="build" />
        <unzip src="${harness-runtime-dst}" dest="build" />
    </target>

    <target name="qa-run-category" >
        <ant dir="build/qa" target="run-categories" inheritall="false">
            <property name="run.categories" value="${category}"/>
        </ant>
    </target>
    
    <target name="qa-run-test" >
        <script language="javascript">
            var testdash = project.getProperty("test");
            project.setProperty("testslash", testdash.replaceAll("-", "/"));
        </script>
        
        <ant dir="build/qa" target="run-tests" inheritall="false">
            <property name="run.tests" value="${testslash}"/>
        </ant>
    </target>
    
    <target name="clean" >
        <delete dir="tmp" />
        <delete dir="build" />
    </target>
    
</project>
