How to access version property from BOM with Gradle?

Solution for How to access version property from BOM with Gradle?
is Given Below:

I’m migrating a small multi-module project from Maven to Gradle, to evaluate and (hopefully) to learn something.

subprojects {
    group = ""

    apply plugin: "java"

    repositories {

    dependencies {
        implementation platform("org.springframework.boot:spring-boot-dependencies:2.5.2")

This is what I have so far. Despite a small problem it’s already working. As you can see, I’m importing org.springframework.boot:spring-boot-dependencies as platform dependency / BOM (Bill of Materials). As far as I understand this is equivalent to a Maven parent. spring-boot-dependencies already defines almost everything I’m using in this project. However, I’m also using Lombok. Luckily Spring takes care of that too.

This work as expected for the compileOnly dependency org.projectlombok:lombok. The problem is the annotationProcessor. Compiling the project results in an error:

Execution failed for task [...].
> Could not resolve all files for configuration [...].
   > Could not find org.projectlombok:lombok:.
     Required by:
         project [...]

If I change it to something like this:


… it works. But I want Gradle to use the version definition for Lombok from spring-boot-dependencies, because I don’t want to define it again myself. With Maven I could just use the Maven property lombok.version. So I also tried something like this:


Unfortunately, this result in another error:

A problem occurred evaluating root project [...].
> Could not get unknown property 'lombok' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

What is the Gradle equivalent to access a defined version property from a platform dependency / BOM?