Hi all! I try to migrate a hand-crafted version ca...
# community-support
t
Hi all! I try to migrate a hand-crafted version catalogue (i.e. scripted in a
SettingsPlugin
) to one using a central
gradle/libs.versions.toml
file to support GHs Renovate bot in a multi-component build. Previously I had this specific settings plugin applied to all of my sub component's settings like this:
Copy code
pluginManagement {
    includeBuild("../build-settings")
}

plugins {
    id("my.custom.settings.plugin")
}
and it all worked fine. Now that move to that
libs.versions.toml
I cannot get this working any longer, since each subcomponent has it's own reference to a
gradle
subdir, i.e.
ROOT/gradle/libs.versions.toml
exists, but
ROOT/subcomponent/gradle/libs.versions.toml
obviously does not and if I try to manually "correct" that like this via
Copy code
if (!settings.project(":").name.contains("monorepo")) {
  settings.dependencyResolutionManagement {
     versionCatalogs {
        create("libs") {
          from(
            settings.layout.settingsDirectory.file("gradle/libs.versions.toml")
          )
        }
     }
  }
}
I get
ROOT/subcomponent/gradle/
referenced and even if I fix that, Gradle will still tell me
Copy code
java.lang.RuntimeException: org.gradle.internal.typeconversion.UnsupportedNotationException: Cannot convert the provided notation to an object of type Dependency: /local/path/to/monorepo/gradle/libs.versions.toml.
The following types/formats are supported:
  - String or CharSequence values, for example 'org.gradle:gradle-core:1.0'.
  - Maps, for example [group: 'org.gradle', name: 'gradle-core', version: '1.0'].
  - FileCollections, for example files('some.jar', 'someOther.jar').
  - Projects, for example project(':some:project:path').
  - ClassPathNotation, for example gradleApi().
So what am I doing wrong / how can I effectively share a TOML version catalogue in a multi-component scenario?
t
Have you tried using
files()
rather tha
file()
to get a
FileCollection
rather than
RegularFile
?
t
I will be damned, I did not...
Yes, this works, thanks for this obvious solution 🙂