STUDY/GRADLE
[Gradle] GRADLE 5 + BOOT 2.x + Lombok 빌드 이슈
simongs
2020. 5. 3. 10:40
▣ 이슈상황
- Gradle 버젼업 하기 전에 잘 빌드되는 소스 코드가 오류가 난다.
- 오류 메시지 :: cannot find symbol
▣ Project 설정 후 테스트 과정에서 오류
// build.gradle
compile("org.projectlombok:lombok")
// Java class with lombok annotation
@Getter
public class TestDto {
private String name;
private int amount;
@Builder
public TestDto(String name, int amount) {
this.name = name;
this.amount = amount;
}
}
▣ Error Message
Testing started at 10:58 AM ...
> Task :cleanTest
> Task :compileJava
> Task :processResources NO-SOURCE
> Task :classes
> Task :compileTestJava FAILED
book/web/dto/DtoTest.java:20: error: cannot find symbol
.builder()
^
symbol: method builder()
location: class TestDto
book/web/dto/DtoTest.java:25: error: cannot find symbol
assertThat(dto.getName()).isEqualTo(name);
^
symbol: method getName()
location: variable dto of type TestDto
book/web/dto/DtoTest.java:26: error: cannot find symbol
assertThat(dto.getAmount()).isEqualTo(amount);
^
symbol: method getAmount()
location: variable dto of type TestDto
3 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileTestJava'.
> Compilation failed; see the compiler error output for details.
* 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
BUILD FAILED in 0
▣ 해결방안
1. build.gradle 을 수정한다.
- Reference
dependencies {
compileOnly("org.projectlombok:lombok")
testCompileOnly("org.projectlombok:lombok")
annotationProcessor("org.projectlombok:lombok")
testAnnotationProcessor("org.projectlombok:lombok")
}
2. gradle version 을 낮춘다. (Not Recommended)
./gradlew wrapper --gradle-version 4.10.2