Gradle version catalogue - share a version between multiple toml files

Viewed 9

Currently I do something like following:

Toml Files

// tools.versions.toml
[versions]
kotlin = "1.7.10"
gradle = "7.2.1"
maven = "2.0"
// libs.versions.toml
[versions]
kotlin = "1.7.10"
[libraries]
kotlin = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" }

Version Catalogue

versionCatalogs {

// would be nice to be able to define a version here and use them inside the toml files...
// val kotlin = "1.7.10"

create("tools") {
    from(files("gradle/tools.versions.toml"))
}

create("libs") {
    from(files("gradle/libs.versions.toml"))
}

// others...

}

Question

Is there a way to share a version definition in my setup and still keep the separate files? Doing all inside the versionCatalogs blog allows me to do this but only if I define everything there instead of the files...

I don't mind changing the toml files to gradle.kts files, but I could not find a way to merge multiple gradle.kts files - but maybe there's a way in this direction?

Note

I'm not looking for a different solution like buildSrc or composite builds, I'd like to use the gradle version catalogue.

0 Answers
Related