Reputation: 533
Is it possible to automatically embed javadoc into a jar from NetBeans? In the program there is an option to generate javadoc. This creates a finished website generated from the existing javadoc in your project. There is also an option to attach javadoc to a project or jar so that it shows up in the suggestions. Right now, when I click build and then take the jar and add it to a project on a different computer the javadoc for jar does not show up. I have to manually copy it over to the computer and attach it, which seems redundant when I should just be attached automatically.
Things I tried:
Upvotes: 1
Views: 1167
Reputation: 347334
Assuming you're using the default Ant based Netbeans Project, you will need to modify the projects build.xml
file to include the generation of the JavaDocs and copy the resulting files into the build.classes.dir
so they can be Jar'ed
Start by clicking on the Files
tab, next to the Projects
tab, expand your project node and you will see the build.xml
file in the root directory
Next, the you need to inject some functionality into the build process, between the compile and jar processed. Reading through information inside the build.xml
, the -post-compile
target is probably the place we want to get started.
After having a read of the javadoc
ant task documentation, I added this to my build.xml
<target name="-post-compile">
<javadoc
sourcepath="src"
defaultexcludes="yes"
destdir="javadocs"
author="true"
version="true"
use="true"
windowtitle="The name of your API"
>
<doctitle><![CDATA[<h1>My API</h1>]]></doctitle>
<bottom><![CDATA[<i>Copyright © 2000 Dummy Corp. All Rights Reserved.</i>]]></bottom>
<tag name="todo" scope="all" description="To do:"/>
<link offline="true" href="http://docs.oracle.com/javase/8/docs/api/" packagelistLoc="C:\tmp"/>
<link href="http://docs.oracle.com/javase/8/docs/api/"/>
</javadoc>
<copydir src="javadocs" dest="${build.classes.dir}/javadocs"/>
</target>
So, I placed this directly under <import file="nbproject/build-impl.xml"/>
in the build.xml
file, but it's placement should matter.
This generated a jar file with the javadocs
directory (and the javadocs) included in it
Upvotes: 2