Mystified by a new error running javadoc

Today I’m seeing a new error running the “javadoc” task (or even “gradle tasks”), even after removing the one line that I thought I changed since I successfully ran this yesterday.

When I run “gradle tasks” from the root of the project, I get this:

FAILURE: Build failed with an exception.
* Where:
Build file '...\git\oce_usl\usl-parent\build.gradle' line: 72
* What went wrong:
A problem occurred evaluating root project 'usl-parent'.
> Could not find method top() for arguments [Unified Service Layer - top] on task ':jacoco-aggregate:javadoc' of type org.gradle.api.tasks.javadoc.Javadoc.

Here is the “javadoc” block from my top-level build.gradle, inside a “subprojects” block:

  javadoc {
      top "Unified Service Layer - top"
      bottom "Unified Service Layer - bottom"
      windowtitle "Unified Service Layer - windowtitle"
      doctitle "Unified Service Layer - title"
      footer "Unified Service Layer - footer"
      header "Unified Service Layer - header"
      level "public"
      packagesheader "Unified Service Layer - packagesheader"
      
      taglets "com.att.det.taglet.ValidationConstraintsTaglet", "com.att.det.taglet.ValidationConstraintsCombinedTaglet"
      
      options.addStringOption('Xdoclint:none')
  }

I looked back in my Emacs shell buffer, and I see that I successfully ran this yesterday. The only thing that I tried to add was the “options.addStringOption()” call, but even after I removed that line and tested again, I get the same error.

Hello,

I think you run into two different kinds of issue here.

First issue is that the syntax javadoc {} is a configuration closure on a Javadoc object, if you do not specify the sender, methods will be sent to that object. However, bottom, windowTitle and others are methods belonging to the StandardJavadocDocletOptions class. Use the getOptions() getter of the Javadoc object to obtain a reference on that object:

javadoc {
    options.bottom "foobar"
}

Second issue is that it looks like the top method does not exist. While the javadoc -top flag does exist, I was not able to find the matching method in Gradle public API. You may be able to workaround this with:

javadoc {
    // See https://github.com/Netflix/Hystrix/blob/master/hystrix-core/build.gradle for example
    options.addStringOption('top').value = 'some text'
}