Java – Automatically generating source and doc jars in Netbeans


Is there a way to automatically generate source and javadoc jars in Netbeans? Ideally I would like to place jars of my source and JavaDoc in the dist folder each time i build.

Best Solution

Here is what I personally add to my ant files (build.xml) :

<target description="bundle sources in a jar" name="package-sources">
  <jar basedir="src" destfile="dist/${}-sources.jar"/>
<target depends="-javadoc-build" description="bundle javadoc in a jar" name="package-doc">
  <jar basedir="dist/javadoc" destfile="dist/${}-javadoc.jar"/>

With Netbeans call these targets manually, or you can use hook targets :

<target name="-post-jar" depends="package-sources, package-doc" />