Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I pull the version for the Gradle org.springframework.boot plugin from my Gradle platform definition

I really like the Gradle java-platform feature. I've created my own platform that bundles spring-boot-dependencies along with other things. Now I have (shortened for clarity):

plugins {
    id 'org.springframework.boot' version '2.4.1'
}

dependencies {
    implementation platform("my-group:my-base-bom:1.0.0")
}

And I'd like the spring boot plugin version to automatically adjust to match the version of spring-boot-dependencies that is bundled in my platform (so if the platform went to SB 2.5.0 then plugin would do the same without my needing to change the build.gradle.

I can't figure out how to do it though without resorting to external variables. Is it possible?

like image 325
Dennis Doubleday Avatar asked Oct 21 '25 04:10

Dennis Doubleday


1 Answers

Not possible. Currently, there are (3) ways to define versions for plugins:

In the Gradle file directly:

// build.gradle.kts

plugins {
    id("org.springframework.boot") version "2.4.1"
}

In the plugins dependencies spec:

// settings.gradle.kts

pluginManagement {
    plugins {
        id("org.springframework.boot") version "2.4.1"
    }
}

or with a resolution rule:

// settings.gradle.kts

pluginManagement {
    resolutionStrategy {
        eachPlugin {
            if (requested.id.id == "org.springframework.boot") {
                useVersion("2.4.1")
            }
        }
    }
}

All of which do not accept a platform, only a single version variable.

Another way I tested, but ultimately did not work was utilizing the buildscript:

// build.gradle.kts

buildscript {
    dependencies {
        classpath(platform("io.mateo.sample:platform-bom:1.0.0-SNAPSHOT"))
        classpath("org.springframework.boot:spring-boot-gradle-plugin")
    }
}

As mentioned at the start, it's not possible.

like image 83
Francisco Mateo Avatar answered Oct 24 '25 09:10

Francisco Mateo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!