Open Grimoren opened 2 years ago
The easy work-around is to make it an implementation dependency, instead of a compileOnly. Has implications, and compileOnly would be preferred, but gets you running
Actually it still identifies it as not used in implementation, as well.
You might want to just use the gradle-lombok plugin instead and not have to deal dependency scopes for lombok anymore: https://plugins.gradle.org/plugin/io.freefair.lombok
The Getter
annotation and any other annotation that has a RetentionPolicy @Retention(RetentionPolicy.SOURCE)
will always fail. The Gradle Lint plugin uses ASM to visit compiled class files and review if dependencies declared are in use in said compiled classes. JLS 9.6.4.2 states that the information about this annotation will not be present in the compiled class file:
Annotations may be present only in source code, or they may be present in the binary form of a class or interface. An annotation that is present in the binary form may or may not be available at run time via the reflection libraries of the Java SE Platform. The annotation type java.lang.annotation.Retention is used to choose among these possibilities.
If an annotation a corresponds to a type T, and T has a (meta-)annotation m that corresponds to java.lang.annotation.Retention, then: ... If m has an element whose value is java.lang.annotation.RetentionPolicy.SOURCE, then a Java compiler must ensure that a is not present in the binary representation of the class or interface in which a appears.
https://docs.oracle.com/javase/specs/jls/se14/html/jls-9.html#jls-9.6.4.2
The only way I can imagine one would be able to determine if these annotations were being used would be to investigate the source file itself.
needs fixing unused-dependency this dependency is a service provider unused at compileClasspath time and can be moved to the runtimeOnly configuration build.gradle:19 compileOnly(group: "org.projectlombok", name: "lombok", version: projectlombokLombokVersion)
fixed unused-dependency this dependency is unused and can be removed build.gradle:19 compileOnly(group: "org.projectlombok", name: "lombok", version: projectlombokLombokVersion)
error: package lombok does not exist import lombok.Getter; ^