Hi, I'm having difficulty with an imported BOM. I ...
# community-support
j
Hi, I'm having difficulty with an imported BOM. I have 3 projects: 1. library-a has a BOM 2. library-b has a BOM that imports library-a's BOM 3. application-a imports library-b's BOM I get the following warning / error only in the application-a build:
Copy code
Errors occurred while building effective model from /Users/jdolan/.m2/repository/library-b/1.0.0/library-b-1.0.0.pom:
        'dependencies.dependency.version' for library-a is missing. in library-b:1.0.0
Sure enough, when I look at the published
library-b.pom
in
~/.m2
, there is no version specified for
library-a
. Why? And why does the
library-b
build not complain about an unresolved version for
library-a
?
library-a BOM build.gradle:
Copy code
import org.springframework.boot.gradle.plugin.SpringBootPlugin

plugins {
    id 'java-platform'
    id 'maven-publish'
}

javaPlatform {
    allowDependencies()
}

dependencies {
    api platform(SpringBootPlugin.BOM_COORDINATES)

    constraints {
        api project(':baz')
        api project(':bat')
    }
}
library-b BOM build.gradle:
Copy code
plugins {
    id 'java-platform'
    id 'maven-publish'
}

javaPlatform {
    allowDependencies()
}

dependencies {
    api platform(libraryA.bom)

    constraints {
        api project(':foo')
        api project(':bar')
    }
}
I should note that the Spring dependencies resolve just fine in my consuming project. Obviously, their BOM is correctly authored with versions etc.
It occurred to me that maybe library-b's BOM shouldn't specify versions for library-a dependencies -- because that's what importing library-a's BOM should handle.
But then, why does this not work correctly in the consuming application? It's like application-a doesn't "recursively" import project-a's BOM.
Any ideas / suggestions / things I could share that would help diagnose this?
As a workaround, I have explicitly imported my library-b BOM in each library-b module, and that seems to fix it. Why? I do not know. The "core" library-b module declares
api platform(libraryA.bom)
, and all library-b modules depend on library-b:core. So why wasn't the
libraryA.bom
dependency transitive to them as it should have been? And only missing in projects consuming
library-b
, but apparently fine in
library-b
itself.
Very weird. I'm tempted to report this as a bug.
t
I'm afraid you don't give enough details for anyone to help. Maybe create a MCVE? (you'd need one anyway if it indeed is a bug)
👍 1
👆 1
v
Besides the question per-se, if it is important that all your
library-b
modules have the same version at runtime, you want to depend on the BOM on all of them anyway so that at least Gradle consumers automatically get proper version alignment of your modules. See https://blog.gradle.org/alignment-with-gradle-module-metadata for more information. 🙂
👍 1