This message was deleted.
# general
s
This message was deleted.
m
Looks like there is a plugin for that -
Copy code
id 'io.spring.dependency-management'
d
m
interesting, this uses a maven pom to enforce dependency management rather that doing it directly - which both seems backwards and perfect for my (and I guess most people’s) needs 🙂 Thanks
v
I wouldn't use the Spring plugin if it is just for getting the versions from a Maven POM. The Spring plugin can do more, like porting over imho bad Maven behavior over to Gradle. If you want the additional features, you can use it, but to just get the version constraints from a BOM, just use the built-in support using
platform(...)
. If it is not about consuming an existing BOM from another project, there might be better ways. If you just want a central catalog of versions for your project, use a version catalog. If you want to project in your build like a BOM module in Maven, that influences dependency resolution, including transitive dependencies, define a platform (if you publish that, it comes out as BOM for Maven consumers and with better metadata for Gradle consumers. If you want the versions of all projects in a build always aligned at consumer, use a platform that depends on the individual projects and make the projects also depend on the platform, ... It's all in the docs too. 🙂
4
m
FWIW, I needed exact functionality that spring plugin gave me, i.e. guarantee that a specific dependency is always the expected version without depending on it. Need to look at the
platform()
stuff to see if that can do the same
v
Theres's also
enforcedPlatform()
, but that should usually not be used, but only in edge cases, and never in a library project.
a
There are also constraints that might act similarly as
dependencyManagement
block from Maven or Spring dependency plugin. To always use some version strictly, you would use:
Copy code
dependencies {    
    constraints {
        // or with a !! shortcut: implementation("org.apache.httpcomponents:httpclient:4.5.3!!")
        implementation("org.apache.httpcomponents:httpclient") {
            version {
                strictly("4.5.3")
            }
        }
    }
}
I think the main difference with Maven would be how
pom
is handled. With Gradle you set just the pom’s version in constraints, but if you want for a pom to actually affect other dependencies, you add it to
dependencies
block as a
platform
. While in Maven pom will affect other dependencies as soon as you add it to the
dependencyManagement
block.
v
Isn't what you said, that it is the same? M: you add to dependency management => it works G: you add it as platform => it works Both: you add it as dependency => it does nothing (given it is a BOM without dependenices)
And just to be clear for M3, what
platform
and
enforcedPlatform
do, is exactly adding those constraints, just in a bunch from a BOM or Gradle Platform, isn't it?
a
I meant: If you look at Gradle’s
constraints {}
block as an direct alternative to a Maven’s
dependencyManagement
and you want to translate
dependencyManagement
block from your Maven project to Gradle
constraints
, there is a difference I believe
v
Ah, I see