<?xml version="1.0" encoding="UTF-8"?>
<!--

The contents of this file are subject to the terms of the Common Development
and Distribution License (the License). You may not use this file except in
compliance with the License.

You can obtain a copy of the License at http://www.netbeans.org/cddl.html
or http://www.netbeans.org/cddl.txt.

When distributing Covered Code, include this CDDL Header Notice in each file
and include the License file at http://www.netbeans.org/cddl.txt.
If applicable, add the following below the CDDL Header, with the fields
enclosed by brackets [] replaced by your own identifying information:
"Portions Copyrighted [year] [name of copyright owner]"

The Original Software is NetBeans. The Initial Developer of the Original
Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
Microsystems, Inc. All Rights Reserved.
-->
<project name="xtest-unit" basedir="." default="all">

    <condition property="do.we.need.to.parse.project.xml.file" >
        <or>
            <not><isset property="code.name.base.dashes" /></not>
            <not><isset property="module.run.classpath" /></not>
        </or>
    </condition>
    <available file="../nbproject/project.properties" property="do.we.need.to.process.properties.file" />

    <target name="init-nbproject-property-files">
        <!-- Synch the following property loads with NbModuleProject.makeEvalDefs: -->
        <property file="../nbproject/private/private.properties"/>
        <property file="../nbproject/project.properties"/>
    </target>
    
    <target name="init-read-property-files" depends="init-nbproject-property-files" if="do.we.need.to.process.properties.file" >
        <!-- #45947 - properties from project.properties with test-unit-sys-prop
            prefix are treated as system properties. -->
        <property name="temp.properties.path" location="${xtest.workdir}/sys/temp.properties"/>
        <copy file="../nbproject/project.properties" tofile="${temp.properties.path}"/>
        <replace file="${temp.properties.path}" token="test-unit-sys-prop." value="xtest.userdata|"/>
        <property file="${temp.properties.path}"/>
        <!-- Properties with prefix "xtest.userdata|" are written to the
            ${xtest.workdir}/sys/userdata.properties in module_harness.xml#write-property 
            target and then loaded as system properties before test execution. -->
        <delete file="${temp.properties.path}"/>
        <!-- #45947 end -->
    </target>
    
    <target name="init-parse-project-xml" depends="init-read-property-files" if="do.we.need.to.parse.project.xml.file" >
        <!-- Use harness instead of nbbuild/nbantext.jar" -->
        <property name="harness.dir" location="${netbeans.dest.dir}/harness"/>
        <taskdef name="parseprojectxml" classname="org.netbeans.nbbuild.ParseProjectXml" classpath="${harness.dir}/tasks.jar"/>
        <property name="avoid.pubpkg.warnings" value="true"/> <!-- XXX release55 hack only -->
        <property name="avoid.friend.warnings" value="true"/> <!-- XXX release55 hack only -->
        <parseprojectxml project=".." codenamebasedashesproperty="code.name.base.dashes" modulerunclasspathproperty="module.run.classpath"/>
    </target>
        
    <target name="init" depends="init-parse-project-xml,init-read-property-files">
        <property name="module.jar.dir" value="modules"/>
        <property name="module.jar.basename" value="${code.name.base.dashes}.jar"/>
        <property name="module.jar" value="${module.jar.dir}/${module.jar.basename}"/>
        <property name="build.compiler.debug" value="true"/>
        <property name="build.compiler.source" value="${ant.java.version}"/>
        <property name="build.compiler.deprecation" value="true"/>
        <property name="build.sysclasspath" value="ignore"/>
    </target>
    
    <target name="init-cp" depends="init">
        <!-- These properties cannot be undefined. -->
        <property name="cp.extra" value=""/>
        <property name="test.unit.cp.extra" value=""/>
        <property name="test.unit.run.cp.extra" value=""/>
        <path id="test.unit.compile.cp">
            <pathelement path="${module.run.classpath}"/>
            <pathelement location="${cluster}/${module.jar}"/>
            <pathelement path="${cp.extra}"/>
            <pathelement path="${test.unit.cp.extra}"/>
        </path>
        <path id="test.unit.run.cp">
            <path refid="test.unit.compile.cp"/>
            <pathelement path="${test.unit.run.cp.extra}"/>
        </path>
    </target>
    
    <!-- ========= -->
    <!-- Compilers -->
    <!-- ========= -->
    
    <target name="default-compiler">
        <!-- Build tests but not build module sources. -->
        <ant dir=".." target="do-test-build"/>
        <packageTests/>
    </target>
    
    <!-- ========= -->
    <!-- Executors -->
    <!-- ========= -->
    
    <target name="run-unit-test" depends="init-cp">
        <executeTests pluginname="jvm">
            <classpath refid="test.unit.run.cp"/>
        </executeTests>
    </target>
        
</project>
