[RSS]

How do I have two source directories within one module?

In your module's project.properties, define two properties like this:

extra.src.dir=src2
cp.extra=${extra.src.dir}

where the value of extra.source.dir is the name of the folder directly inside your module which will contain an additional source tree.

In your project.xml, add this just before </data>:

     
<extra-compilation-unit>
    <package-root>${extra.src.dir}</package-root>
</extra-compilation-unit>

In your module's build.xml, you need to override the compile target to add a hook for compiling the code in your extra source tree:

<target name="compile" depends="projectized-common.compile">
    <mkdir dir="${build.classes.dir}"/>
    <javac srcdir="${extra.src.dir}" 
        destdir="${build.classes.dir}" 
        debug="${build.compiler.debug}" 
        debuglevel="${build.compiler.debuglevel}" 
        deprecation="${build.compiler.deprecation}" 
        optimize="${build.compiler.optimize}" 
        source="${javac.source}" 
        target="${javac.target}" 
        includeantruntime="false">

        <classpath refid="cp"/>
    </javac>
</target>

You should have a look at the harness/README file under your Netbeans installation directory it is a treasure trove of information about issues like this one. The build harness is capable of doing a good deal more than the GUI currently supports (since NetBeans 6.0).


Applies to: NetBeans IDE 6.x Platforms: All