Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Application build failed cause of Lombok

I've faced problem when building my project that uses Lombok after swapping to different git branch. I get multiple exceptions generally of these two types:

  1. for classes like
@Setter(onMethod_ = @Autowired)
public class ClassA{

   private ClassC c;

}

I get

java: cannot find symbol
  symbol:   method onMethod_()
  location: @interface lombok.Setter
  1. for classes like
@Builder
public class ClassB{

}

I get

java: cannot find symbol
  symbol:   class ClassBBuilder
  location: class com.example.application.ClassB

in methods like

private ClassB.ClassBBuilder getBuilder(Object input) {
    //builder init
}
  1. And after all I get StackOverflowError.

The problem is fixed after running gradle:clean -> gradle:build. But comes up again after swapping branch. Some more information: I'm using Intellij Idea 2020.3.3 Ultimate Edition and checkbox "Enable Annotation processing" is checked. Here are some parts of my build.gradle:

import org.springframework.boot.gradle.plugin.SpringBootPlugin

plugins {
    id 'net.ltgt.apt' version '0.19'
    id 'net.ltgt.apt-idea' version '0.19'
    id 'org.springframework.boot' version '2.3.2.RELEASE' apply false
}

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'net.ltgt.apt'
apply plugin: 'net.ltgt.apt-idea'
apply plugin: 'io.spring.dependency-management'

repositories {
    maven { url = 'https://repo.maven.apache.org/maven2' }
}

dependencyManagement {
    imports {
        mavenBom SpringBootPlugin.BOM_COORDINATES
    }
}

dependencies {
    compileOnly 'org.projectlombok:lombok'
    annotationProcessor 'org.projectlombok:lombok'
    annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
//other dependencies
}

Does anybody know what could cause this problem?

like image 889
Andrei Yusupau Avatar asked Oct 27 '22 13:10

Andrei Yusupau


1 Answers

This issue has been resolved in a newer version of Lombok. Please update the Lombok version to 1.18.18 and it will fix the issue.

like image 186
Sidharth Avatar answered Oct 29 '22 22:10

Sidharth