Hi there, I’ve got a multi-project build, and in the root project I define a few configurations to aid with packaging. Using a BOM for constraints in all subprojects.
subprojects {
dependencies {
implementation platform(group: 'org.eclipse.jetty', name: 'jetty-bom', version: 9.4.27.v20200227)
}
}
configuration {
someLib
}
dependencies {
someLib project(":some-subproject")
}
In the subproject:
dependencies {
implementation group: 'com.example', name: 'my-artifact'
implementation group: 'org.eclipse.jetty', name: 'jetty-server'
implementation group: 'org.eclipse.jetty', name: 'jetty-servlets'
}
The artifact my-artifact has a transitive dependency on ‘jetty-server’ but not on ‘jetty-servlets’.
The subproject compiles and dependencies resolve correctly with the expected constraints introduced by the BOM.
However, in the root project, the configuration ‘someLib’ which depends on the subproject, the jetty-servlets dependency does not resolve, only dependencies that also are transitively required by the subproject, and they resolve to the version in the transitive dependency and ignore the BOM.
+--- org.eclipse.jetty:jetty-server -> 9.4.22.v20191022 (*)
+--- org.eclipse.jetty:jetty-servlet -> 9.4.22.v20191022 (*)
+--- org.eclipse.jetty:jetty-servlets FAILED
+--- org.eclipse.jetty:jetty-util -> 9.4.22.v20191022
From the debug log, it appears that the version from the BOM is not considered in trying to resolve the artifact:
2020-03-03T11:21:27.121-0800 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Detected non-existence of module 'org.eclipse.jetty:jetty-servlets:' in resolver cache 'BintrayJCenter'
Any idea why resolution is not honoring the BOM in this case?
My current workaround is to create a distribution directory in the subproject that resolves correctly and consume those files instead of using the custom configuration in the root project.
e.g. from project(':my-subproject').tasks.dist