General Metadata—Folders

<folders> [optional] enumerates file locations that are "owned" by this project.

By default, everything underneath the main project directory (parent of nbproject) is owned by this project, unless it is part of a nested project. "Ownership" in the IDE can easily be seen by selecting a file in the Projects, Files, or Favorites tab and checking the title bar of the main window. A project decides how files it owns should be treated for purposes of compilation, etc.

Using <folders> you can specify that externally located files are also to be owned by this project. Permitted child elements are <source-folder> and <build-folder>.

<source-folder>
    <label>Project Sources</label>
    <location>${home}</location>
</source-folder>
        

This specifies that everything under ${home} (which must have been defined using <properties>, above) is owned by this project. This directory will be displayed as e.g. <project name> - Project Sources in the Files tab. If you use File > New to add a text file to the project, Project Sources will be offered as a possible location.

<source-folder>
    <label>Main Java Sources</label>
    <type>java</type>
    <location>${home}/java</location>
</source-folder>
        

This specifies that ${home}/java should be treated as a folder of Java sources arranged in a package structure. File > New will offer this as a choice for where to put new Java classes.

Note that the / in ${home}/java works on Windows as well as Unix, just as in Ant; \ is permitted and equivalent. Also note that relative paths are resolved against the project directory, just as they would be from a build.xml at top level using basedir="." (or no explicit basedir).

In NetBeans 6.0+, if you use the /2 schema (a different namespace), you can also specify optional includes and/or excludes (in the usual Ant patternset format) and encoding for given folder, e.g.:

<source-folder>
    <label>Main Java Sources</label>
    <type>java</type>
    <location>${home}/java</location>
    <includes>packageOfInterest/</includes>
    <excludes>**/unusedPackages/</excludes>
    <encoding>UTF-16</encoding>
</source-folder>
        

The above declaration will show any subpackages of packageOfInterest which do not contain unusedPackages as a package component.

<build-folder>
    <location>${build}</location>
</build-folder>
        

This specifies that ${build} is a folder which contains build products from the project. It is thus to be "owned" by the project but not expected to be shared with other users (e.g. in version control). Not much used yet, but planned to be: