https://gradle.com/ logo
Title
h

Hantsy Bai

05/25/2023, 7:10 AM
I tried to update my Gradle scripts and use version catalog to declare the dependencies and versions in the file gradle/libs.versions.toml . I really like the bundles to group a collection of libs, but if one lib requires some exclusion of other deps I have to exclude it from this bundle and declare it in the project build.gradle.kts like following . If possible to exclude deps in a lib in the TOML file?
testImplementation(libs.starterTest) {
        // use mockk as mocking framework
        exclude(module = "mockito-core")
        exclude(module = "android-json")
    }
v

Vampire

05/25/2023, 8:57 AM
No, a version catalog is like its name suggests, just a catalog of artifacts with versions to pick from. The same entry could be used at different locations with different needs for excludes or artifacts or similar, so all this is to be declared at usage side and cannot be defined in a version catalog.
h

Hantsy Bai

05/25/2023, 11:43 AM
maven BOM can define dep with name and version , also can declaration of excluding transitive deps by default.
v

Vampire

05/25/2023, 11:50 AM
Well, a version catalog has practically nothing to do or in common with a Maven BOM, except that you define versions in them. The according construct of a Maven BOM in Gradle is a Platform. You can also combine a Platform and a Version Catalog without problems.
BOMs and platforms influence the resolution process and are also mainly to control version of transitive dependencies. Version catalogs are really just a list of coordinates with version but are effect-wise the same as specifying the dependency explicitly, just that you can update the version without invalidating all caches and have a central place to define the versions.
m

melix

05/26/2023, 10:24 AM
in other words, to the question "should I use a platform or a catalog", the answer is often use both 🙂 https://docs.gradle.org/current/userguide/platforms.html#sub:platforms-vs-catalog