franzbecker / gradle-lombok

Gradle plugin for Lombok support

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

javadoc is not being generated for lombok annotated field

anidotnet opened this issue · comments

If I have a class like as below and a lombok annotated field,

public class Main {
    /**
     * Determines if the it is opened in readonly mode.
     *
     * @return true if it is opened in readonly mode; otherwise false.
     * */
    @Getter @Setter(AccessLevel.PACKAGE)
    private boolean readOnly;
}

the gradle plugin is not generating javadoc for readOnly. The field itself is missing from javadoc. It is not recognising it as a public entity.

buildscript {
    repositories {
        maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
        maven { url "https://plugins.gradle.org/m2/" }
        jcenter()
        mavenCentral()
        mavenLocal()
    }
    dependencies {
        classpath "io.franzbecker:gradle-lombok:1.7"
        classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.3'
    }
}

apply plugin: 'io.franzbecker.gradle-lombok'

lombok {
        version = "1.16.10"
        sha256 = ""
    }

repositories {
        mavenCentral()
        maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
        mavenLocal()
    }

Note that this plugin only simplifies the usage of Lombok, it does not add features to it.
What you're describing seems to be an issue to Lombok itself, not for this plugin.

Also, the behavior you describe is the one I would expect from Lombok. The annotations do not change the visibility of the field itself, so it should not show up in JavaDoc. It would be nice to have this JavaDoc on the getter / setter method, though. If this does not happen this would be a good feature request for the Lombok project itself (https://projectlombok.org/).

Sorry, I have not explained it clearly. What I meant is that the public getter method is not there in the generated javadoc. The declaration should be visible at least in the javadoc. And lombok already has this functionality to copy field's documentation to getter/setter's documentation - https://projectlombok.org/features/GetterSetter.html.

If you generate a Javadoc after delomboking, there are public getter and setter methods in the Javadoc.

e.g.)

plugins {
    id 'io.franzbecker.gradle-lombok' version '1.8'
}

import io.franzbecker.gradle.lombok.task.DelombokTask

// Lombok Task
lombok {
    version = "1.16.10"
}

// Delombok Task
task delombok( type: DelombokTask ) {
    description = 'Generates delomboked source.'

    sourceSets.all {
        if ( it.name != SourceSet.TEST_SOURCE_SET_NAME ) {
            it.allJava.srcDirs.each {
                args( it, '-d', "${buildDir}/${delombok.name}" )
            }
        }
    }
}

// Javadoc Task
javadoc {
    dependsOn delombok

    source = file( "${buildDir}/${delombok.name}" )
    failOnError = false
}

The configuration from @ahamana works fine. I don't think it makes sense to let this plugin configure the javadoc task - as this would probably cause problems for people having their own configuration.

I've updated the documentation accordingly.

A slightly improved definition would look like this:

// Delombok Task
task delombok(type: DelombokTask, dependsOn: compileJava) {
    ext.outputDir = file("$buildDir/delombok")
    outputs.dir(outputDir)
    sourceSets.main.java.srcDirs.each { 
        inputs.dir(it)
        args(it, "-d", outputDir)
    }
}

// Javadoc Task
javadoc {
    dependsOn delombok
    source = delombok.outputDir
    failOnError = false
}

Using this definition and Gradle 3.1 the delombok task will be UP-TO-DATE if called repeatedly with no changed input. With Gradle < 3.1 there is a bug that prevents the task from being UP-TO-DATE.