gradlew clean build 시 error 발생(java.lang.IllegalAccessError: class lombok.javac.apt.LombokProcessor)

2022. 4. 11. 14:35CM/Gradle

반응형

gradlew clean build시 오류

mac에서  IDE가 아닌 gradlew로 빌드 시키려는데 아래와 같이 오류가 발생했다.
현재 mac에서 jdk는 디폴트로 11을 사용하고 있었는데 git clone 받은 프로젝트는 jdk 8을 사용하고 있었다.

> Task :compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> java.lang.IllegalAccessError: class lombok.javac.apt.LombokProcessor (in unnamed module @0x57e49654) 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 @0x57e49654

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.4.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 1s
2 actionable tasks: 2 executed

문제는 lombok이 jdk 버전 영향을 받는것 같다.
그래서 해결방안으로 -Dorg.gradle.java.home 옵션을 줘서 해결할 수 있습니다.(8을 바라보도록 함)
 ex) ./gradlew clean build -Dorg.gradle.java.home=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home

반응형