13

I have published maven bom and imported it in top level build.gradle.kts as:

allProjects {
  dependencies {
        implementation(platform("com.example:some-dependencies:1.2.3"))
    }
}

And then in libs.versions.toml:

[libraries]
some-bom = { group = "com.example", name="some-dependencies", version="1.2.3" }

When I change first code sample to:

allProjects {
  dependencies {
        implementation(platform(libs.some.bom))
    }
}

I get:

Could not resolve: javax.xml.bind:jaxb-api
Could not resolve: org.springframework.boot:spring-boot-starter-test
...

Is there any way to use Gradle 7 version catalogs with boms?

Hiosdra
  • 332
  • 3
  • 11

1 Answers1

33

In my case, it just worked. I'm working on Android project and my script is just like below:

//libs.versions.toml
[libraries]
deps_okhttp_bom = "com.squareup.okhttp3:okhttp-bom:4.9.1"
deps_okhttp_lib = { module  ="com.squareup.okhttp3:okhttp" }
deps_okhttp_logging_interceptor = { module= "com.squareup.okhttp3:logging-interceptor"}

//build.xml
dependencies {
  implementation platform(libs.deps.okhttp.bom)
  implementation libs.deps.okhttp.lib
  implementation libs.deps.okhttp.logging.interceptor
}

In your example, you just added dependency for BOM. But as BOM is just an spec sheet which describes versions for each libraries, you need to add dependencies for specific libraries.

kingori
  • 2,406
  • 27
  • 30