<?xml version="1.0" encoding="UTF-8"?>
<project basedir=".." name="nb-IDE">
    <import file="../build.xml"/>
    <target depends="compile" name="run-selected-file-in-src">
        <fail unless="run.class">Must set property 'run.class'</fail>
        <java classname="${run.class}" failonerror="true" fork="true">
            <classpath>
                <fileset dir="${basedir}" includes="lib/**/*.jar"/>
                <pathelement location="build/classes"/>
            </classpath>
        </java>
    </target>
    <target depends="compile,compile-tests" name="run-selected-file-in-test">
        <fail unless="run.class">Must set property 'run.class'</fail>
        <java classname="${run.class}" failonerror="true" fork="true">
            <classpath>
                <fileset dir="${basedir}" includes="lib/**/*.jar"/>
                <pathelement location="build/classes"/>
                <pathelement location="build/test"/>
            </classpath>
        </java>
    </target>
    <target depends="compile,compile-tests" name="test-selected-file">
        <fail unless="test.class">Must set property 'test.class'</fail>
        <loadresource property="test.file">
            <string value="${test.class}"/>
            <filterchain>
                <replaceregex flags="g" pattern="\." replace="/"/>
                <replaceregex pattern="$" replace=".class"/>
            </filterchain>
        </loadresource>
        <testng haltOnFailure="true" outputDir="${test.result.dir}" verbose="2" workingDir="${basedir}">
            <classpath>
                <pathelement path="${compile.test.dir}"/>
                <pathelement path="${instr.dir}"/>
                <pathelement path="${compile.dir}"/>
                <fileset dir="${lib.dir}" includes="**/*.jar"/>
                <fileset dir="${test.lib.dir}" includes="**/*.jar"/>
            </classpath>
            <jvmarg value="-noverify"/>
            <classfileset dir="${compile.test.dir}" includes="${test.file}"/>
        </testng>
    </target>

    <target depends="compile,compile-tests" name="test-selected-method">
        <fail unless="test.class">Must set property 'test.class'</fail>
        <loadresource property="test.file">
            <string value="${test.class}"/>
            <filterchain>
                <replaceregex flags="g" pattern="\." replace="/"/>
                <replaceregex pattern="$" replace=".class"/>
            </filterchain>
        </loadresource>
        <testng haltOnFailure="true" outputDir="${test.result.dir}" verbose="2" workingDir="${basedir}" methods="${test.class}.${method}">
            <classpath>
                <pathelement path="${compile.test.dir}"/>
                <pathelement path="${instr.dir}"/>
                <pathelement path="${compile.dir}"/>
                <fileset dir="${lib.dir}" includes="**/*.jar"/>
                <fileset dir="${test.lib.dir}" includes="**/*.jar"/>
            </classpath>
            <jvmarg value="-noverify"/>
            <classfileset dir="${compile.test.dir}" includes="${test.file}" />
        </testng>
    </target>

    <target depends="compile,compile-tests" name="test-debug-selected-file">
        <fail unless="debug.class">Must set property 'debug.class'</fail>
        <delete dir="${test.result.dir}"/>
        <mkdir dir="${test.result.dir}"/>
        <mkdir dir="${test.result.dir}/raw/"/>
        <nbjpdastart addressproperty="jpda.address" name="ffdec" transport="dt_socket">
            <classpath id="cp">
                <pathelement path="${compile.dir}"/>
                <fileset dir="${lib.dir}" includes="**/*.jar"/>
                <fileset dir="${test.lib.dir}" includes="**/*.jar"/>
            </classpath>
        </nbjpdastart>
        <loadresource property="debug.file">
            <string value="${debug.class}"/>
            <filterchain>
                <replaceregex flags="g" pattern="\." replace="/"/>
                <replaceregex pattern="$" replace=".class"/>
            </filterchain>
        </loadresource>
        <testng haltOnFailure="true" outputDir="${test.result.dir}" verbose="2" workingDir="${basedir}">
            <classpath>
                <pathelement path="${compile.test.dir}"/>
                <pathelement path="${compile.dir}"/>
                <fileset dir="${lib.dir}" includes="**/*.jar"/>
                <fileset dir="${test.lib.dir}" includes="**/*.jar"/>
            </classpath>
            <jvmarg value="-noverify"/>
            <jvmarg value="-Xdebug"/>
            <jvmarg value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}"/>
            <classfileset dir="${compile.test.dir}" includes="${debug.file}"/>
        </testng>
    </target>

    <target depends="compile,compile-tests" name="test-debug-selected-method">
        <fail unless="debug.class">Must set property 'debug.class'</fail>
        <delete dir="${test.result.dir}"/>
        <mkdir dir="${test.result.dir}"/>
        <mkdir dir="${test.result.dir}/raw/"/>
        <nbjpdastart addressproperty="jpda.address" name="ffdec" transport="dt_socket">
            <classpath id="cp">
                <pathelement path="${compile.dir}"/>
                <fileset dir="${lib.dir}" includes="**/*.jar"/>
                <fileset dir="${test.lib.dir}" includes="**/*.jar"/>
            </classpath>
        </nbjpdastart>
        <loadresource property="debug.file">
            <string value="${debug.class}"/>
            <filterchain>
                <replaceregex flags="g" pattern="\." replace="/"/>
                <replaceregex pattern="$" replace=".class"/>
            </filterchain>
        </loadresource>
        <testng haltOnFailure="true" outputDir="${test.result.dir}" verbose="2" workingDir="${basedir}" methods="${debug.class}.${method}">
            <classpath>
                <pathelement path="${compile.test.dir}"/>
                <pathelement path="${compile.dir}"/>
                <fileset dir="${lib.dir}" includes="**/*.jar"/>
                <fileset dir="${test.lib.dir}" includes="**/*.jar"/>
            </classpath>
            <jvmarg value="-noverify"/>
            <jvmarg value="-Xdebug"/>
            <jvmarg value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}"/>
            <classfileset dir="${compile.test.dir}" includes="${debug.file}"/>
        </testng>
    </target>

    <target depends="compile,compile-tests" name="debug-selected-file-in-test">
        <fail unless="debug.class">Must set property 'debug.class'</fail>
        <delete dir="${test.result.dir}"/>
        <mkdir dir="${test.result.dir}"/>
        <mkdir dir="${test.result.dir}/raw/"/>
        <nbjpdastart addressproperty="jpda.address" name="ffdec" transport="dt_socket">
            <classpath>
                <pathelement path="${compile.dir}"/>
                <pathelement path="${compile.test.dir}"/>
                <fileset dir="${lib.dir}" includes="**/*.jar"/>
                <fileset dir="${test.lib.dir}" includes="**/*.jar"/>
            </classpath>
        </nbjpdastart>
        <java classname="${debug.class}" fork="true">
            <classpath>
                <pathelement path="${compile.dir}"/>
                <pathelement path="${compile.test.dir}"/>
                <fileset dir="${lib.dir}" includes="**/*.jar"/>
                <fileset dir="${test.lib.dir}" includes="**/*.jar"/>
            </classpath>
            <jvmarg value="-Xdebug"/>
            <jvmarg value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}"/>
        </java>
    </target>
    <target depends="compile" name="debug-selected-file-in-src">
        <fail unless="debug.class">Must set property 'debug.class'</fail>
        <ant antfile="build.xml" inheritall="false" target="build"/>
        <nbjpdastart addressproperty="jpda.address" name="jxar" transport="dt_socket">
            <classpath>
                <fileset dir="${basedir}" includes="lib/**/*.jar"/>
                <pathelement location="build/classes"/>
            </classpath>
        </nbjpdastart>
        <java classname="${debug.class}" fork="true">
            <classpath>
                <fileset dir="${basedir}" includes="lib/**/*.jar"/>
                <pathelement location="build/classes"/>
            </classpath>
            <jvmarg value="-Xdebug"/>
            <jvmarg value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}"/>
        </java>
    </target>
    <target name="-profile-check">
        <startprofiler freeform="true"/>
    </target>
    <target depends="build,-profile-check" if="profiler.configured" name="profile-selected-file-in-src">
        <fail unless="profile.class">Must set property 'profile.class'</fail>
        <java classname="${profile.class}" fork="true">
            <classpath>
                <fileset dir="${basedir}" includes="lib/**/*.jar"/>
                <pathelement location="build/classes"/>
            </classpath>
            <jvmarg line="${agent.jvmargs}"/>
        </java>
    </target>

</project>