spring-gradle-plugins / dependency-management-plugin

A Gradle plugin that provides Maven-like dependency management functionality
686 stars 85 forks source link

Integrate with Gradle Version Catalogs #306

Closed madorb closed 3 years ago

madorb commented 3 years ago

This might be a long shot, as i don't know what it'd entail, but it looks like gradle 7's new version catalogs don't play nicely with this plugin - and would be awesome if it did! (or if gradle would get it together and add real support for BOM semantics directly :-) )

Import maven bom:

dependencyManagement {
  imports {
    // able to resolve the version from the toml file with a get
    mavenBom("org.springframework.boot:spring-boot-dependencies:${libs.versions.spring.boot.get()}")
  }
}

Declare a dependency in my libs.versions.toml catalog:

[libraries]
jackson-core = { module = "com.fasterxml.jackson.core:jackson-core" }

in build.gradle.kts declare a dependency on this version:

implementation(libs.jackson.core)

it fails with:

Could not find com.fasterxml.jackson.core:jackson-core:.

So it appears like when not specifying the version, whatever is generating the bindings from the toml is unaware of the versions provided by the mavenBom import, and thus defaults to an unknown version .

madorb commented 3 years ago

Argh, i think this was actually a problem with my multi-module configuration. Closing for the moment

nancheung commented 2 years ago

Hello, I also encountered this problem. How do you integrate catalog with this plug-in?

wilkinsona commented 2 years ago

@nancheung97 It’s not clear what “this problem” is. It appears that @madorb’s problem was caused by a problem with his multi-module configuration.

If you believe you’ve found a problem with this plugin and you’d like someone to spend some time trying to help you, please spend some time opening a new issue and providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to the new issue.

You may also want to investigate using Gradle’s native bom support via a platform or enforced platform rather than this plugin.

madorb commented 2 years ago

one rough evdge for this is that you can't seem to use the dep references created by the catalog from the mavenBom

e.g. one must do this: mavenBom("com.foo.bar:mydep-bom:${rootProject.libs.versions.foo.bom.get()}")

vs:

mavenBom(libs.foo.bom)

image