Lombok with Gradle (io.freefair.lombok plugin) creates tons of JavaDoc warnings

Viewed 649

I'm using Gradle to include Lombok, and I'm using the freefair lombok plugin, as recommended;

plugins {
    id "io.freefair.lombok" version "6.0.0-m2"
    // ...
}

Given the following class:

/**
 * Request to add a task to an existing todo list.
 * 
 * @author b_muth
 *
 */
@Value
public class AddTaskRequest{
  /**
   * Identifier of the list.
   */
  @NonNull UUID todoListId;
  
  /**
   * Name of the task to be added.
   */
  @NonNull String taskName;
}

I get the following warnings:

 C:\...\generated\sources\delombok\...\AddTaskRequest.java:23: warning: no comment

  public AddTaskRequest(@NonNull final UUID todoListId, @NonNull final String taskName)

C:\...\generated\sources\delombok\...\AddTaskRequest.java:38: warning: no @return
  public UUID getTodoListId() { 

and there are much more. As far as I can tell, freefair uses delombok, but doesn't create adequate JavaDoc in the generated sources. Here's an excerpt from the generated class:

/**
 * Request to add a task to an existing todo list.
 * 
 * @author b_muth
 */
public final class AddTaskRequest {
  /**
   * Identifier of the list.
   */
  @NonNull
  private final UUID todoListId;
  /**
   * Name of the task to be added.
   */
  @NonNull
  private final String taskName;

  public AddTaskRequest(@NonNull final UUID todoListId, @NonNull final String taskName) {
    if (todoListId == null) {
      throw new NullPointerException("todoListId is marked non-null but is null");
    }
    if (taskName == null) {
      throw new NullPointerException("taskName is marked non-null but is null");
    }
    this.todoListId = todoListId;
    this.taskName = taskName;
  }
  /**
   * Identifier of the list.
   */
  @NonNull
  public UUID getTodoListId() {
    return this.todoListId;
  }
...
}

Is there to stop these warnings from occuring?

1 Answers

Please have a look at the (de)lombok documentation here, which explains how javadoc comments are handled: https://projectlombok.org/features/GetterSetter

NEW in lombok v1.12.0: javadoc on the field will now be copied to generated getters and setters. Normally, all text is copied, and @return is moved to the getter, whilst @param lines are moved to the setter. Moved means: Deleted from the field's javadoc. It is also possible to define unique text for each getter/setter. To do that, you create a 'section' named GETTER and/or SETTER. A section is a line in your javadoc containing 2 or more dashes, then the text 'GETTER' or 'SETTER', followed by 2 or more dashes, and nothing else on the line. If you use sections, @return and @param stripping for that section is no longer done (move the @return or @param line into the section).

EDIT:

Instead of fixing the javadoc comments itself, you can also silence the warnings by adding the -Xdoclint:-missing option to your javadoc task:

tasks.withType(Javadoc) {
    options.addBooleanOption("Xdoclint:-missing", true)
}
Related