Gradle multi-module project can not process Lombok annotations

Viewed 18

I have a multi-module project using Gradle as the build system:

|- RootDirectory
       |- settings.gradle
       |- ServiceInterface
              |- build.gradle
       |- Service
              |- build.gradle

This is settings.gradle:

rootProject.name = 'multi-module-demo'
include 'ServiceInterface'
include 'Service'

ServiceInterface

This is just a simple package where some model classes are defined. I use Lombok to simplify my code.

// build.gradle

plugins {
    id 'java'
}

repositories {
    mavenCentral()
}

dependencies {
    compileOnly 'org.projectlombok:lombok:1.18.24'
    annotationProcessor 'org.projectlombok:lombok:1.18.24'
}
// Apple.java

@Builder
public class Apple {
  ...
}

Service

This package contains some API endpoints built on top of Spring Boot:

// build.gradle

plugins {
    id 'org.springframework.boot' version '2.7.3'
    id 'io.spring.dependency-management' version '1.0.13.RELEASE'
    id 'java'
}

sourceCompatibility = '11'

repositories {
    mavenCentral()
}

dependencies {
    implementation project(':ServiceInterface')
    implementation 'org.springframework.boot:spring-boot-starter-web'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
// AppleController

@RestController
public class AppleController {
    @GetMapping
    public Response listApples() {
        final var apple1 = Apple.builder().build();
        ...
    }
}

When I ran ./gradlew build in the root directory, it failed to find the symbol builder in this line Apple.builder(). Any idea why this happened? Thanks.

0 Answers
Related