Hibernate has a lot of dependencies to manage. I really like the idea of version-catalogs; in fact we had something similar for ages (hibernate-orm/libraries.gradle at main · hibernate/hibernate-orm · GitHub) and glad to see that has been formalized!
The catalog benefits the Hibernate build itself, but I’d also like to start producing a platform to help users/comsumers. That would lead to a LOT of duplication though. Basically, for most of the dependencies we would need an entry in both.
So I had the brilliant idea to combine these and have the platform use the version-catalog. E.g.
// settings.gradle
enableFeaturePreview("VERSION_CATALOGS")
dependencyResolutionManagement {
versionCatalogs {
libs {
version( "jpa", "3.0.0" )
alias( "jpa" ).to( "jakarta.persistence", "jakarta.persistence-api" ).versionRef( "jpa" )
alias( "jta" ).to( "jakarta.transaction", "jakarta.transaction-api" ).version( "2.0.0")
...
}
}
}
And then,
// the platform's build.gradle
plugins {
id 'java-platform'
}
dependencies {
constraints {
api libs.jpa
api libs.jta
...
}
}
However, this does not work. Specifically, while the generated module.json
seems correct, the generated POM is definitely not - it does not contain any constraints.
Should this work? If so, any idea what I am doing wrong?
P.S. My other post (Sharing information between Settings and Project via Plugin) relates to this. Specifically, we need to be able to pass a version for jakarta.persistence-api
at the command line to be able to scriptably test against new JPA versions. But I have not found a good solution to sharing such details between Settings and Project. Is the only option to extract that command line arg twice?
P.S.S. I ask this because the user guide does not mention they can be used together and even has a longish discussion about when to use which, largely implying that you should pick one or the other.
Thanks!