Saturday, March 15, 2014

Libgdx Extensions Javadocs or How to Extract Javadocs from Source Jars


A lot of open source projects like Libgdx package sources in jars. So how do you generate Javadocs with the Javadoc command directly from a jar file?

You can't. You have to extract the jar first.

Specifically for Libgdx, extensions are not documented in the online Javadoc.

One alternative is to just attach the source jars with whatever editor you are using, such as Eclipse. For Eclipse, right click on the project -> build path -> configure build path. Then there should be a window similar to this:

Click the plus symbol next to the jar, then double click source attachment. A dialog box will appear to allow you to attach the source jar.

However, this does not solve the original problem. You want an HTML Javadoc Index.html file to look at, possibly on a multi-monitor setup. No problem. Create a small script to extract the jar files and build the Javadoc for you (or use Ant or build tool of your choosing).

The below is specific to Libgdx but could be modified for any open source project with source jars. Download the Libgdx nightly here


touch ./extensions-javadoc

chmod 755 ./extensions-javadoc
3. Open extensions-javadoc with your favourite text editor and paste below


mkdir extension-sources
cd extension-sources
jar -xvf ./../extensions/gdx-audio/sources/gdx-audio-sources.jar
jar -xvf ./../extensions/gdx-bullet/sources/gdx-bullet-sources.jar
jar -xvf ./../extensions/gdx-controllers/sources/gdx-controllers-android-sources.jar
jar -xvf ./../extensions/gdx-controllers/sources/gdx-controllers-desktop-sources.jar
jar -xvf ./../extensions/gdx-controllers/sources/gdx-controllers-gwt-sources.jar
jar -xvf ./../extensions/gdx-controllers/sources/gdx-controllers-sources.jar
jar -xvf ./../extensions/gdx-freetype/sources/gdx-freetype-sources.jar
jar -xvf ./../extensions/gdx-image/sources/gdx-image-sources.jar
jar -xvf ./../extensions/gdx-jnigen/sources/gdx-jnigen-sources.jar
jar -xvf ./../extensions/gdx-tiled-preprocessor/sources/gdx-tiled-preprocessor-sources.jar
jar -xvf ./../extensions/gdx-tools/sources/gdx-tools-sources.jar

javadoc -d ./../docs-extensions -sourcepath ./ -subpackages com

4. Save and run script
Rejoice at your newly available HTML Javadocs!

1 comment:

  1. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Java developer learn from Java Training in Chennai. or learn thru Java Online Training from India . Nowadays Java has tons of job opportunities on various vertical industry.