0

I know there are other similar questions like this, but I have gone through all of them, and none worked for me, hence my asking it here.

I'm using gradle for my project, and when I build, it builds successfully, but when I try to compile using:

/gradlew app:compileJava

I get this error:

Execution failed for task ':app:compileJava'.
> java.lang.IllegalAccessError: class lombok.javac.apt.LombokProcessor (in unnamed module ...) cannot access class com.sun.tools.javac.processing.JavacProcessingEnvironment (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.processing to unnamed module ...

My dependency for lombok currently looks like this:

dependencies {
    annotationProcessor 'org.projectlombok:lombok'
    testAnnotationProcessor  'org.projectlombok:lombok'
    compileOnly 'org.projectlombok:lombok'
    testCompileOnly 'org.projectlombok:lombok'

...
}

I have also tried adding a specific version number to the dependences like for example:

annotationProcessor 'org.projectlombok:lombok:1.18.20'

And I was still getting same error.

I'm using jdk 15 (tried using 17, 16 and 11, same error).

When I check my annotation processor in intelliJ, I see there is a processor path with lombok version 1.18.16. I don't know if this might be the issue, but when I delete the cache in .gradle folder, after building, it pops up again. Here is a screenshot.

annotation processor screenshot

Please any help would be really appreciated.

user8107351
  • 367
  • 4
  • 20

1 Answers1

0

So what I finially did, was to downgrade my java version to 8, but there are some packages that requires at least version 11 to function. So I added this in my build.gradle:

java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(11)
    }
}

Note: You should have both version 11 Nand 8 installed for this to work.

user8107351
  • 367
  • 4
  • 20