<?xml version="1.0" encoding="UTF-8"?>
<project name="Java2D" basedir="." default="jar">

    <import file="nbproject/jdk.xml"/>
    
    <target name="-prop-init">
        <property file="user.build.properties"/>
        <property file="build.properties"/>
    </target>

    <target name="-init" depends="-prop-init,-jdk-init"/>

    <target name="compile" depends="-init" description="Compile main sources.">
        <mkdir dir="${classes.dir}"/>
        <javac srcdir="${src.dir}" destdir="${classes.dir}" debug="${debug}" deprecation="${deprecation}">
            <classpath path="${cp}"/>
        </javac>
        <copy todir="${classes.dir}">
            <fileset dir="${src.dir}"/>
        </copy>
    </target>

    <target name="jar" depends="compile" description="Build JAR file for main sources.">
        <jar jarfile="${jar}" compress="true">
            <manifest>
                <attribute name="Main-Class" value="${main.class}"/>
            </manifest>
            <fileset dir="${classes.dir}"/>
        </jar>
    </target>

    <target name="run" depends="compile" description="Run application.">
        <fail unless="main.class">Must set property 'main.class' (e.g. in build.properties)</fail>
        <java classname="${main.class}" fork="true" failonerror="true">
            <classpath path="${run.cp}"/>
        </java>
    </target>

    <target name="run-applet" depends="jar" description="Run applet.">
        <exec executable="${nbjdk.appletviewer}">
            <arg file="${applet.html}"/>
        </exec>
        <!-- To view in regular web browser instead:
        <nbbrowse file="${applet.html}"/>
        -->
    </target>
    
    <target name="javadoc" depends="-init" description="Build Javadoc.">
        <mkdir dir="${javadoc.dir}"/>
        <javadoc destdir="${javadoc.dir}">
            <classpath path="${cp}"/>
            <sourcepath>
                <pathelement location="${src.dir}"/>
            </sourcepath>
            <fileset dir="${src.dir}"/>
        </javadoc>
    </target>

    <target name="clean" depends="-init" description="Clean build products.">
        <delete dir="${build.dir}"/>
        <delete file="${jar}"/>
    </target>

    <target name="profile">
        <ant antfile="nbproject/netbeans-targets.xml" target="profile"/>
    </target>

</project>
