0

I am using spring-boot-gradle-plugin:2.4.13 with Gradle 5.6.4.

We are using the "configurations" block of the dependency-management-plugin to limit dependency management to a set of specific Gradle configurations, as shown below

apply plugin: "io.spring.dependency-management"
dependencyManagement {
    configurations(compile,compileOnly, runtime,annotationProcessor) {
        imports {
            mavenBom(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES)
        }
    }
}

This works as expected however, if we subsequently apply the org.springframework.boot plugin, then the specified configurations are ignored and dependency management is used for all configurations.

I see that the spring-boot-gradle-plugin performs this action in response to the DependencyManagementPlugin being applied, which seems like it might be the issue.

So I would like to know whether it is possible to apply the org.springframework.boot plugin such that dependency management is only used within a specific set of configurations.

1 Answers1

0

I don't think what you want to do is possible. I don't see anything in the documentation of the Spring Boot Gradle plugin that allows this type of customization. With that said, I think your only option is to not use the Spring Dependency Management plugin and use Gradle platform instead. This will allow you do do the following:

dependencies {
    implementation(platform(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES))
}

https://docs.spring.io/spring-boot/docs/current/gradle-plugin/reference/htmlsingle/#managing-dependencies.gradle-bom-support

This will allow you to apply the Spring Boot Gradle plugin, but choose which configurations to apply its BOM it to.

GreenSaguaro
  • 2,968
  • 2
  • 22
  • 41
  • Thanks for the reply @GreenSaguaro, I came to a similar conclusion. Unfortunately this solution will not work for now as we are stuck with Gradle 5.6.4. – Simon Hutchinson Jul 06 '23 at 16:56
  • Then I guess your last resort is to tell them that you cannot complete your job without a newer version of Gradle. – GreenSaguaro Jul 06 '23 at 16:59