简体   繁体   中英

Gradle can not build with lombok

Currently can not build a new project with 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 was a common issues with older versions of gradle and lombok and have seen similar questions on this site, however I'm using more recent version and could not get passed this issue

Environment info

  • Java: openjdk 13.0.1 2019-10-15 (This is the OpenJ9 version and NOT the HotSpot version)
  • Javac: 13.01
  • Gradle: 6.0.1
  • Lombok: 1.18.10

Build.gradle (Built using Spring initialiser )

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'
    }
}

Things I've tried

  • I've tried swapping out deps for the Lombok gradle plugin, as stated here :
  • Nearly all other similar issues on stack overflow simply referred to updating Gradle to a version 4.5+ and a Lombok version of 1.18+

Thanks in advance

I'm having the same issue right now with OpenJ9 13.0.1.9, but it works fine with 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 Open J9 to run my executable JAR.

I had a similar problem, but it seems to be a bug related to OpenJ9.

The solution was to use the latest edge version, as commented below. https://github.com/rzwitserloot/lombok/issues/2501#issuecomment-664330803

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM