'Configuring Javadoc with SBT (-overview tag unrecognized)

Trying to manage a Java project with SBT. The SBT documentation says to set javadoc options like this:

Compile / doc / javacOptions ++= Seq("-notimestamp", "-linksource")

The Javadoc documentation says to include an overview, use the -overview option like this:

When you run the Javadoc tool, you specify the overview comment file name with the -overview option.

Then it gives as a real world example:

% javadoc -sourcepath /java/jdk/src/share/classes \
    -overview /java/jdk/src/share/classes/overview.html

I can create the javadocs with the doc target, so I know I've got water through the pipes. But now I add:

Compile / doc / javacOptions ++= Seq("-overview overview.html")

to add the overview documentation, and it fails. It's not just that the overview.html isn't getting included (i.e. it's not that I've put my overview.html in the wrong place). The whole build target blows up and I get the error:

[error] compiler message file broken: key=javadoc.err.msg arguments=javadoc, invalid flag: -overview overview.html, {2}, {3}, {4}, {5}, {6}, {7}

So it's seeing the option and passing it to javadoc. What's more, in the info output it tells me what options are available:

[info] javadoc: Usage:
[info]       javadoc [options] [packagenames] [sourcefiles] [@files]
[info]   where options include:
...
[info] javadoc:     -overview <file>
[info] javadoc:                   Read overview documentation from HTML file
...

So it's sort of saying: "you can't use -overview, but you have to use -overview".

This appears to be unexpected. Like, when similar errors come up in forums, these are fairly deep bugs in the Java compilers. It would be unfortunate if that was the case. And the error persists across OpenJDK 11.0.2, 12.0.2, and 17.0.2. I have also tried it specifying the path to the overview.html file:

-overview src/main/java/overview.html

And also with the fully specified path from root, with the same behavior. It does not seem to have anything to do with the location of the overview.html file.

But this seems like something pretty basic that anyone with a Java project under SBT would need to do. So how do I get a doc target in SBT for Java sources to handle the -overview option to Javadoc???



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source