<?xml version="1.0" encoding="utf-8"?>
<project name="nb_targets" basedir=".">
  <!-- 
    ======================
    DEBUG PROJECT 
    ======================
    The following target debugs the project in the IDE.
    -->
  <target name="debug" depends="compile" if="netbeans.home" description="Debug Project">
    <nbjpdastart name="My App" addressproperty="jpda.address" transport="dt_socket">
      <classpath refid="run.classpath" />
      <!-- Optional - If source roots are properly declared in project, should
                            work without setting source path.     
            <sourcepath refid="debug.sourcepath"/> -->
    </nbjpdastart>
    <java fork="true" classname="com.me.myapp.Main">
      <jvmarg value="-Xdebug" />
      <jvmarg value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}" />
      <classpath refid="run.classpath" />
    </java>
  </target>
  <!--
    To map this target to the Debug File command, add the following to <ide-actions> in 
    project.xml:
    
    <action name="debug">
        <script>path/to/my/nb_targets.xml</script>
        <target>debug</target>
    </action>
    -->
  <!-- 
    ======================
    DEBUG SINGLE FILE 
    ======================
    The following target debugs the currently selected file in the IDE.
    -->
  <target name="debug-selected-files" depends="compile" if="netbeans.home" description="Debug a Single File">
    <fail unless="classname">Must set property 'classname'</fail>
    <nbjpdastart name="${classname}" addressproperty="jpda.address" transport="dt_socket">
      <classpath refid="run.classpath" />
      <!-- Optional - If source roots are properly declared in project, should
            work without setting source path.
            <sourcepath refid="debug.sourcepath"/> -->
    </nbjpdastart>
    <java fork="true" classname="${classname}">
      <jvmarg value="-Xdebug" />
      <jvmarg value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}" />
      <classpath refid="run.classpath" />
    </java>
  </target>
  <!--
    To map this target to the Debug File command, add the following to <ide-actions> in 
    project.xml:
    
    <action name="debug.single">
        <target>debug-selected-files</target>
        <context>
            <property>classname</property>
            <folder>${src.dir}</folder>
            <pattern>\.java$</pattern>
            <format>java-name</format>
            <arity>
                <one-file-only/>
            </arity>
        </context>
    </action>
    -->
  <!-- 
    ======================
    FIX AND CONTINUE
    ======================
    The following target compiles and reloads the currently selected file in the IDE without
    stopping the debugging session.
    -->
  <target name="debug-fix">
    <javac srcdir="${src.dir}" destdir="${classes.dir}" debug="true">
      <classpath refid="javac.classpath" />
      <include name="${fix.file}.java" />
    </javac>
    <nbjpdareload>
      <fileset dir="${classes.dir}">
        <include name="${fix.file}.class" />
      </fileset>
    </nbjpdareload>
  </target>
  <!--
    To map this target to the Fix command, add the following to <ide-actions> in 
    project.xml:
    
    <action name="debug.fix">
        <target>debug-fix</target>
        <context>
            <property>fix.file</property>
            <folder>${src.dir}</folder>
            <pattern>\.java$</pattern>
            <format>relative-path-noext</format>
            <arity>
                <one-file-only/>
            </arity>
        </context>
    </action>
    -->
  <!-- 
    ======================
    RUN SINGLE FILE 
    ======================
    The following target runs the currently selected file in the IDE.
    -->
  <target name="run-selected-files" depends="compile" description="Run Single File">
    <fail unless="classname">Must set property 'classname'</fail>
    <java classname="${classname}">
      <classpath refid="run.classpath" />
    </java>
  </target>
  <!--
    To map this target to the Run File command, add the following to <ide-actions> in 
    project.xml:
    
    <action name="run.single">
        <target>run-selected-files</target>
        <context>
            <property>classname</property>
            <folder>${src.dir}</folder>
            <pattern>\.java$</pattern>
            <format>java-name</format>
            <arity>
                <one-file-only/>
            </arity>
        </context>
    </action>
    -->
  <!-- 
    ======================
    COMPILE SINGLE FILE 
    ======================
    The following target compiles the currently selected file in the IDE.
    -->
  <target name="compile-selected-files" depends="compile">
    <fail unless="files">Must set property 'files'</fail>
    <mkdir dir="${classes.dir}" />
    <javac srcdir="${src.dir}" destdir="${classes.dir}" includes="${files}">
      <classpath refid="javac.classpath" />
    </javac>
  </target>
  <!--
    To map this target to the Compile File command, add the following to <ide-actions> in 
    project.xml:
    
    <action name="compile.single">
        <target>compile-selected-files</target>
        <context>
            <property>files</property>
            <folder>${src.dir}</folder>
            <pattern>\.java$</pattern>
            <format>relative-path</format>
            <arity>
                <separated-files>,</separated-files>
            </arity>
        </context>
    </action>
    -->
</project>
