Adding a custom task to the NetBeans 4.1 build process is easier than I though it would be. In 3.6 you simply right clicked on the build file and selected the target from the context menu. In 4.1 at first it seems you can't do that because the build file is largely managed for you but in actual fact you can quite easily. The only difference is that you have to switch to the files tab to get to the actual build file as it doens't show up under the project tab.
To create your custom target simply add it to the build.xml file. I added the following target to copy a production build to another location. Because the copy can take twice the time it takes to do the build I didn't want this happening every time which is why I wanted it as a seperate task.
<target name="production-build" description="Production Build" depends="clean, compile"> <delete dir="/foo/bar/builds/baz" failonerror="false"/> <copy todir="/foo/bar/builds/baz" overwrite="true"> <fileset dir="build/web"/> </copy> </target>
To use the task right click on the build file and select Run Task. The second level context menu should include the task production-build. If you don't provide a description the task will appear on another submenu called Other Tasks. As you can see you can even depend on the tasks in the normal build process. Note that to depend on the -post-compile task you don't, as I first though, depend on the -post-compile task. Instead depend on the compile task which actually comes after the -post-compile task and correctly depends on the rest of the compililation tasks. Have a look in the build-impl.xml file for more details.