Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate javadoc only with JRE

I would like to be able to generate javadoc for my maven projects even when running under a JRE instead of a JDK, where the javadoc command invoked by maven is found. In other words, not relying on anything but what is in the JRE and what Maven can download and use as artifacts.

Is there any easy way to generate javadocs at all with Maven without needing to use code only found in the JDK?


EDIT: Apparently it is important to understand why I want to do this. We are a small team in a larger organization with yearly releases of our product suite, which our customers then upgrade when it is convenient for them (due to the sheer scale of the deployments this is expensive and time demanding, so it is common to skip one or several releases) and we make a living of being able to provide bugfixes and new functionality on short notice for existing deployments on whatever version the customer in question is running. As an example I recently did a bugfix for a component I wrote five years ago which had been largely untouched since.

Hence long term stability of our build process is very important to us as well as being able to use new versions of Java as they become available. We have migrated our complete build environment to Maven - which buys us permanently frozen artifacts in Maven Central - and have now started to look at what else we need to do.

With the recent announcement that future versions of javac will not support old targets (http://openjdk.java.net/jeps/182) we have concluded that our long term goal is to minimize our dependencies on the underlying Java environment, preferably to just the plain JRE. We are in the process of completely replacing javac from the JDK with the Eclipse compiler which is available from Maven Central, and now we look at javadoc generation.

like image 810
Thorbjørn Ravn Andersen Avatar asked Jun 11 '13 15:06

Thorbjørn Ravn Andersen


1 Answers

Get the source of the JavaDoc from the OpenJDK, and build your own JAR from it with all the relevant JavaDoc classes. Write a maven plugin that relies on your JAR, and call com.sun.tools.javadoc.Main.main from it.

It does not look like you need to open up your sources when using OpenJDK's classes, you should be OK to distribute the resultant plug-in without harsh restrictions.

Even if the terms do not cover the tools, you could write an Open Source GPL-2 plugin for maven, and make it a separate product that you distribute under GPL-2. Your product would then download and install the plugin using maven plugin:download, thus separating out your JavaDoc plugin from the rest of your code.

Of course you should run this suggestion by your legal department before following this advice.

like image 140
Sergey Kalinichenko Avatar answered Sep 20 '22 08:09

Sergey Kalinichenko