Hello good people. Is it possible to have 2 versio...
# gradle
d
Hello good people. Is it possible to have 2 versions catalog ( or some trick to merge two of them )? The scenario is: We have the
main
project and a
sub
project as a submodule. Having different dependency versions caused some troubles, so we wanna align them.
sub
will have some dependencies in its toml file, but
main
would need some dependencies that are not available in
sub
j
That was possible before but it was removed, not sure why cc @melix
v
Yes, you can have any amount of version catalogs without problem
What @Javier is referring to is, that you cannot combine / merge multiple toml files into one version catalog easily. But having multiple version catalogs coming from multiple toml files is no problem at all.
d
How to do that? I tried adding 2
create
but gave me an error
v
Which?
d
Insieme the deoendencyManagement
I'll back on PC soon and let you know
Invalid catalog definition:
- Problem: In version catalog libs, you can only call the ‘from’ method a single time.
But actually I just noticed that changing name to
libs
it works 😕
like
Copy code
dependencyResolutionManagement {
  versionCatalogs {
    create("someLibs") { // before libs
      from(files("gradle/libs.versions.toml"))
    }
    create("coreLibs") {
      from(files("sub/gradle/libs.versions.toml"))
    }
  }
}
v
libs
implicitly imports
gradle/libs.versions.toml
if it exists, so you cannot import another and thus second file into that catalog. The error is a bit misleading and will hopefully be changed.
d
So basically
libs
is always created by defo?
v
So if you want that
libs
, just remove it from your code as it is created automatically
If the file is there, yes
Convention over configuration like everywhere in Gradle
d
Ok, I see! If the file exists then it’s different! Because I got this in pet-project
Copy code
dependencyResolutionManagement {
  versionCatalogs {
    create("libs") {
      from(files("../gradle/libs.versions.toml"))
    }
  }
}
That’s why I got confused
Thank you so much 🎉
838 Views