Customising your build in NetBeans
Build scripts used to be a black-magic art to me, practised only by guru-like coders. Clicking ‘build now!’ on whatever IDE I’m working on used to be enough. Luckily I have now seen the light of Ant and its .NET cousin, Nant, and now I can’t stop tinkering! And my work flow process has much less friction than it used to.
So now I’m going to customise my NetBeans project builds. Its dead easy. NetBeans already uses Ant as its build engine, and provides a file in your project root (build.xml) for you to add in your own build snippets at various stages of the build.
There are 13 pre-defined NetBeans target names that act like hooks. You can override them and bring in your own build processes. For example if you want to copy some files after the jars have been built, write your own target called “-post-jar” in build.xml:
<target name="-post-jar">
<copy todir="${dist.images.dir}">
<fileset dir="./images">
<exclude name="Thumbs.db"/>
</fileset>
</copy>
</target>
Now when you hit ‘build’ in NetBeans, your dist directory will have all the images you copied from your images directory. Nice!
