Java – Gradle cannot be built using lombok

Gradle cannot be built using lombok… here is a solution to the problem.

Gradle cannot be built using lombok

It is currently not possible to build new projects using Gradle and Lombok.

warning: You aren't using a compiler supported by lombok, so lombok will not work and has been disabled.
  Your processor is: org.gradle.api.internal.tasks.compile.processing.IncrementalProcessingEnvironment
  Lombok supports: sun/apple javac 1.6, ECJ
/Users/rich/Desktop/reports/src/main/java/com/example/reports/reportparamters/ReportParameter.java:46: error: cannot find symbol
        filter.setReportParameter(this);

I

know this is a common issue with older versions of Gradle and Lombok and have seen similar issues on this site, but I’m using a newer version and can’t fix this

Environmental information

  • Java: openjdk 13.0.1 2019-10-15 (this is the OpenJ9 version and not the HotSpot version).
  • Javac:13.01
  • Level: 6.0.1
  • Lombok :1.18.10

Build.gradle (using Spring initialiser build).

plugins {
    id 'org.springframework.boot' version '2.2.4.RELEASE'
    id 'io.spring.dependency-management' version '1.0.9.RELEASE'
    id 'java'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '13'

configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
    compileOnly 'org.projectlombok:lombok'
    annotationProcessor 'org.projectlombok:lombok'
    testImplementation('org.springframework.boot:spring-boot-starter-test') {
        exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
    }
}

Something I’ve tried

  • I’ve tried swapping deps for the Lombok gradle plugin, as described in here:
  • Almost all other similar issues regarding Stack Overflow simply refer to updating Gradle to version 4.5+ and Lombok version 1.18+

Thanks in advance

Solution

I’m having the same issue on OpenJ9 13.0.1.9 right now, but it works fine on Zulu Java 13 (zulu13.29.9-ca-jdk13.0.2-win_x64).

So I’m using Zulu when building with Gradle (6.0.1) and opening J9 to run my executable JAR.

Related Problems and Solutions