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 buil
I tried the following on NetBeans IDE 7.2 and it works (assuming that the project name is MyProject)
go to the MyProject directory
open build.xml file in a text editor
add the following lines under the line <import file="nbproject/build-impl.xml"/>
:
<target name="-post-jar" description="bundle sources and javadoc in a jar" depends="javadoc">
<jar compress="${jar.compress}" basedir="${src.dir}" jarfile="${dist.dir}/${application.title}-sources.jar"/>
<jar compress="${jar.compress}" basedir="${dist.javadoc.dir}" jarfile="${dist.dir}/${application.title}-javadoc.jar"/>
</target>
go to nbproject folder and open the project.properties file in a text editor
edit the name of the output binary file (set to the project name.jar by default):
# This directory is removed when the project is cleaned:
dist.dir=dist
dist.jar=${dist.dir}/**MyProject-binaries**.jar
Hope it works with you too.
Please try adding this to build.xml. I've tested it on NetBeans IDE 7.0
<target name="-post-jar" description="bundle sources and javadoc in a jar" depends="javadoc">
<jar compress="${jar.compress}" basedir="${src.dir}" jarfile="${dist.dir}/${application.title}-sources.jar"/>
<jar compress="${jar.compress}" basedir="${test.src.dir}" jarfile="${dist.dir}/${application.title}-test.jar"/>
<jar compress="${jar.compress}" basedir="${dist.javadoc.dir}" jarfile="${dist.dir}/${application.title}-javadoc.jar"/>
</target>
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/${ant.project.name}-sources.jar"/>
</target>
<target depends="-javadoc-build" description="bundle javadoc in a jar" name="package-doc">
<jar basedir="dist/javadoc" destfile="dist/${ant.project.name}-javadoc.jar"/>
</target>
With Netbeans call these targets manually, or you can use hook targets :
<target name="-post-jar" depends="package-sources, package-doc" />