Skip to content

Commit

Permalink
Another harrowing maven-javadoc-plugin workaround
Browse files Browse the repository at this point in the history
As of 5ee9b6b it was possible to generate javadocs, and
today it was not, and that remains unexplained. The version
of maven-javadoc-plugin was still 3.1.1 as it was then. It is
herewith updated to 3.2.0, only because it exists, not because
it solved the problem.

To explain what finally worked around the problem, a few words
about the problem are needed.

The maven-javadoc-plugin is adding a --module-source-path option
when invoking javadoc. It's easy to confirm that javadoc behaves
perfectly with all of the plugin-supplied options except that,
which simply isn't needed.

The plugin isn't merely adding a bogus option, though. It quite
carefully creates a directory, and another, empty, directory
within it, for the unneeded option to point to, with the natural result
that javadoc fails to find the module.

And even combing through AbstractJavadocMojo's code (don't waste
time with its documentation) did not reveal any way to configure
that plugin from the POM to simply stop inserting that option that
makes javadoc fail. Perhaps there is a way and I didn't find it.

Thanks for a workaround to a change in the JDK itself for Java 12.
https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8208609
For other reasons, but saving the day here, they made the
--module-source-path option repeatable starting in Java 12, with a
new syntax option that makes it possible for a correct source path
to be given, and override the bogus one that the plugin is still
putting in.

So with that, there are buildable javadocs again, but only with
Java 12 or later. Builds with Java 9, 10, or 11 simply won't be
able to make the javadocs.

This commit, read together with 5ee9b6b, may serve as an argument
to discontinue using anything as black-boxy and opinionated as
maven-javadoc-plugin to build the javadocs for this project. It
would have been considerably faster to write some JavaScript in
antrun, as we do in some other places, to just run the wretched
javadoc program with the handful of arguments it needs for the job.
That wasn't an option here because the maven-antrun-plugin doesn't
implement MavenReport. It might very well still have been faster
*to write* a reporting plugin exposing JavaScript, add it to the
project, build it, and use it to launch simple javadoc commands.
  • Loading branch information
jcflack committed May 24, 2020
1 parent 1369e5c commit 395ac0d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions pljava-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,14 @@
- this exact potpourri of weirdness just to avoid forcing
- the javadoc tool to do the wrong thing, you would call me
- crazy. See the git commit comment for more explanation.
- Then see the git commit comment for THIS line for even
- MORE explanation.
-->
<additionalOptions>
<additionalOption>--module</additionalOption>
<additionalOption>org.postgresql.pljava</additionalOption>
<additionalOption>--module-source-path</additionalOption>
<additionalOption>org.postgresql.pljava=${basedir}/src/main/java</additionalOption>
</additionalOptions>
<sourceFileExcludes>
<sourceFileExclude>**/org/**/*.java</sourceFileExclude>
Expand Down
4 changes: 4 additions & 0 deletions pljava/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,14 @@
- this exact potpourri of weirdness just to avoid forcing
- the javadoc tool to do the wrong thing, you would call me
- crazy. See the git commit comment for more explanation.
- Then see the git commit comment for THIS line for even
- MORE explanation.
-->
<additionalOptions>
<additionalOption>--module</additionalOption>
<additionalOption>org.postgresql.pljava.internal</additionalOption>
<additionalOption>--module-source-path</additionalOption>
<additionalOption>org.postgresql.pljava.internal=${basedir}/src/main/java</additionalOption>
<additionalOption>--show-module-contents</additionalOption>
<additionalOption>all</additionalOption>
<additionalOption>--show-packages</additionalOption>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.1</version>
<version>3.2.0</version>
<reportSets>
<reportSet>
<reports>
Expand Down

0 comments on commit 395ac0d

Please sign in to comment.