How to set netbean compile a single file?

I'm a new of JME … and i have some ploblem. 

I use netbean 6.0 and i sucessfull in making jme project i can set to run single file and i want to know about to compile a single file how to set it … I look at "http://www.netbeans.org/kb/55/freeform-config.html#compilesingle"  but i don't undertand it and  i can't to set  it this is my code



project.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
    <type>org.netbeans.modules.ant.freeform</type>
    <configuration>
        <general-data xmlns="http://www.netbeans.org/ns/freeform-project/1">
            <!-- Do not use Project Properties customizer when editing this file manually. -->
            <name>jME</name>
            <properties/>
            <folders/>
            <ide-actions>
                <action name="build">
                    <target>compile</target>
                </action>
                <action name="clean">
                    <target>clean</target>
                </action>
                <action name="javadoc">
                    <target>doc</target>
                </action>
                <action name="run">
                    <target>run-testchooser</target>
                </action>
                <action name="test">
                    <target>compile-test</target>
                </action>
                <action name="rebuild">
                    <target>clean</target>
                </action>
       
       
                [b] <action name="compile.single">
                 <script>nbproject/ide-file-targets_1.xml</script> 
                  <context>
                        <property>compile</property>
                        <folder>src</folder>
                        <pattern>.java$</pattern>
                        <format>java-name</format>
                        <arity>
                            <one-file-only/>
                        </arity>
                    </context>
                 </action>[/b]                
             
  
                <action name="run.single">
                    <script>nbproject/ide-file-targets.xml</script>
                    <target>run-selected-file-in-src</target>
                    <context>
                        <property>runclass</property>
                        <folder>src</folder>
                        <pattern>.java$</pattern>
                        <format>java-name</format>
                        <arity>
                            <one-file-only/>
                        </arity>
                    </context>
                </action>
            </ide-actions>
            <view>
                <items>
                    <source-file>
                        <location>build.xml</location>
                    </source-file>
                </items>
                <context-menu>
                    <ide-action name="build"/>
                    <ide-action name="clean"/>
                    <ide-action name="javadoc"/>
                    <ide-action name="run"/>
                    <ide-action name="test"/>
                    <ide-action name="rebuild"/>
                </context-menu>
            </view>
            <subprojects/>
        </general-data>
        <java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/1"/>
    </configuration>
</project>



ide-file-targets_1.xml

<?xml version="1.0" encoding="UTF-8"?>
<project basedir=".." name="jME-IDE">
   
    <!-- TODO: edit the following target according to your needs -->
    <!-- (more info: http://www.netbeans.org/kb/41/freeform-config.html#compilesingle) -->
    <target name="compile-selected-files-in-src">
        <fail unless="files">Must set property 'files'</fail>
        <!-- TODO decide on and define some value for ${build.classes.dir} -->
        <property name="build.classes.dir"  value="build"/>
        <javac destdir="${build.classes.dir}" includes="${files}" source="1.5" srcdir="src"/>
    </target>
</project>





thank for help.. :)

hello akeo563



I don't have my corresponding files to look at here right now but i'll have a closer look when i get home today.



Note this things however:


  • I think You have to create a java project with existing ant script (the build.xml that comes with jme) for this to work
  • the b html tags in Your first script are suspicious and surely don't belong there
  • I don't see You setting the files property that is checked for in target
  • the ${build.classes.dir} and other paths should come from the jme provided build-import.xml so this is required to be

      imported



    edit: typo


Ok, here we go:



this is the relevant part of my project.xml:



                <action name="compile.single">
                    <script>nbproject/ide-file-targets.xml</script>
                    <target>compile-selected-files-in-src</target>
                    <context>
                        <property>files</property>
                        <folder>src</folder>
                        <pattern>.java$</pattern>
                        <format>relative-path</format>
                        <arity>
                            <separated-files>,</separated-files>
                        </arity>
                    </context>
                </action>
                <action name="run.single">
                    <script>nbproject/ide-file-targets.xml</script>
                    <target>run-selected-file-in-src</target>
                    <context>
                        <property>runclass</property>
                        <folder>src</folder>
                        <pattern>.java$</pattern>
                        <format>java-name</format>
                        <arity>
                            <one-file-only/>
                        </arity>
                    </context>
                </action>




and this is my ide-file-targets.xml (the name is not important but it must be referenced from project.xml in the script tags):


<?xml version="1.0" encoding="UTF-8"?>
<project basedir=".." name="jME-IDE">
   
    <import file="../build-import.xml"/>

    <!-- TODO: edit the following target according to your needs -->
    <!-- (more info: http://www.netbeans.org/kb/55/freeform-config.html#compilesingle) -->
    <target name="compile-selected-files-in-src">
        <fail unless="files">Must set property 'files'</fail>
        <!-- TODO decide on and define some value for ${build.classes.dir} -->
        <mkdir dir="${build}"/>
        <javac destdir="${build}" includes="${files}" source="1.5" srcdir="src" classpathref="classpath" fork="true" memoryMaximumSize="128m">
        </javac>
    </target>
   
    <target name="run-selected-file-in-src" description="Run Single File">
      <fail unless="runclass">Must set property 'runclass'</fail>
      <java classname="${runclass}" classpathref="classpath" fork="true">
          <classpath path="${build}"/>
          <jvmarg value="-Djava.library.path=${libs}"/>
      </java>
   </target>
</project>



note however that i tested this on linux only, on other os the quotation marks may vary.
good luck