I'm working on improving the lein-javadoc
plugin to the Leiningen build tool. It runs in a JVM process and has the project's classpath at its disposal. What is the most cross-platform way of generating javadocs?
- Find
$JAVA_HOME/../lib/tools.jar
and include it on the plugin's classpath, then callcom.sun.tools.javadoc.Main
. (Old approach.) - Find
$JAVA_HOME/../lib/tools.jar
and construct a call tojava -cp path/to/tools.jar:rest:of:project:classpath com.sun.tools.javadoc.Main -javadoc -options -here
. (New approach.) - Call
javadoc
and pass it the options.
Choice 3 sounds right in retrospect and I only discovered it after realizing that OpenJDK doesn't have tools.jar. [Actually, it does! I only had the JRE packages installed for that version -- the JDK package does have tools.jar.]
However, before I rework the code to use that, are there any tradeoffs I should know about? Examples:
- Does calling javadoc make things harder on Windows? (Do I have to sniff out that it's Windows and call javadoc.exe instead?)
- Am I likely to encounter problems shelling out to one version of java (whatever's on the shell PATH) and using a different version's tools.jar (the version of the current JVM)?