Here’s a hypothetical minimal example to show how it could work in practice.
Suppose you have two libs.versions.toml files:
[versions]
kotlin = "1.8.0"
coroutines = "1.6.4"
[libraries]
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }[versions]
kotlin = "1.8.10"
serialization = "1.5.0"
[libraries]
kotlin-stdlib-jdk8 = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" }
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "serialization" }After you run this project, you'll get this:
[versions]
# See it took max version
# Which is done by VersionSelectorStrategy
kotlin = "1.8.10"
coroutines = "1.6.4"
serialization = "1.5.0"
[libraries]
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }
kotlin-stdlib-jdk8 = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" }
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "serialization" }From source
./gradlew :application:run --args="/path/to/your/toml/files"Or from .jar
java -jar TomlMerger-0.0.1.jar "/path/to/your/toml/files"There's no active roadmap, but you are free to open an issue or PR.
I've created this project to merge my libs.versions.toml and it works for me
This tool is particularly useful when you are migrating to or managing a large multi-module project where different subprojects might have maintained their own dependency files.
Instead of manually checking and combining them, you can use the merger:
- Gather all scattered
libs.versions.tomlfiles. - Run the merger to create a single source of truth for all dependencies.
- Apply the resulting merged file as your main Gradle Version Catalog.
[versions]
dependency-version = "2.2.0"
[libraries]
dependency-library = { module = "com.example.dep:module", version.ref = "dependency-version" }
[plugins]
dependency-plugin = { id = "org.jetbrains.kotlin.jvm", version.ref = "dependency-version" }