Search code examples
javaspring-bootgradlelombokannotation-processing

Lombok classes not generated


I’m using Intellij IDEA Community Edition (the latest version: Build #IC-242.23339.11, built on September 25, 2024)

here is my build.gradle file:

plugins {
    id 'java'
    id 'org.springframework.boot' version '3.3.4'
    id 'io.spring.dependency-management' version '1.1.6'
}

group = 'org.example'
version = '0.0.1-SNAPSHOT'

java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(17)
    }
}

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'
    testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

tasks.named('test') {
    useJUnit()
} 

gradle-wrapper.properties:

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists 

entity class:

@Builder
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class Test {
    private Long id;
    private String name;
    private int yearOfBirth;
    private String phoneNumber;
    private String secondaryPhoneNumber;
    private LocalDate createdAt;
} 

the java version is: 17.0.12

I’m not doing anything crazy. I just need Lombok to properly generate the Builder class for me but whenever i run

.\gradlew clean build

or

.\gradlew compileJava

then nothing is being generated in build/generated/sources/annotationProcessor/java/main

marking “Enable annotation processing” as checked in the IDEA settings doesnt resolve this issue I also tried to play with different lombok and gradle versions but the issue is still there Invalidating caches did not help either

What am i missing? I’d appreciate the help, thanks in advance!


Solution

  • As stated on the lombok setup page for IntelliJ the plugin needs to be added to the IDE for versions after 2023.1.