Reusing BOM from parent project

Hi,

Problem

i defined a new configuration in root project called “bom” with a platform dependency.

configurations{
    bom
    implementation.extendsFrom bom
}

dependencies {

    bom platform('org.springframework.boot:spring-boot-dependencies:2.1.2.RELEASE')
    implementation 'org.springframework.boot:spring-boot-test'
}

i will reuse the bom configuration in subproject lib1 with this construct

configurations{
    bom
    implementation.extendsFrom bom
}
dependencies {
    bom platform(project(path:":", configuration:"bom"))
    implementation 'org.springframework.boot:spring-boot-test'
}

will be broken by upgrading from 5.6.4 to 6.0 and also in latest 6.8

* Where:
Build file 'C:\Java\DaimlerMRS\gradle-6.8-bom-showcase\lib1\build.gradle' line: 17

* What went wrong:
A problem occurred evaluating project ':lib1'.
> Cannot add attributes or capabilities on a dependency that specifies artifacts or configuration information

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

Sampleproject could be find here

In Branch: use-bom-from-parent

please give me a hint whats going wrong.

thanks
Andreas

Problem clearified and found the solution:

we used to import the parent projects bom configuration as platform(path:':', configuration:'bom') but that failed with missing or wrong attributes/capabilities. But if we’re just using it as project dependency it’s working as it used to.
Not sure why it actually is that way, but the documentation from Aligning dependency versions actually showed us the right way to do it and should be linked in the java-platform plugin documentation.

If interested, here’s the solution branch:

I think you could get root projects’s bom like so:
rootProject.configurations.getByName("bom")

It’s usually not the best idea to reach into other projects models like that.
Besides that, what don’t you like with the solution they already implemented?

I dunno, just saying.
I was actually looking for an answer to my current problem.
Can you take a look, Björn?

Already answered there