Is it possible to declare `libs.versions.toml` in ...
# gradle
z
Is it possible to declare
libs.versions.toml
in a standalone library and have consumers of the library use its versions, plugins, etc?
v
What do you mean with "in a standalone library"? You can publish the toml and then use it other builds if that is what you asked.
z
Sorry, didnt realize how abstract my question was! I mean publishing a library on maven with said libs.versions, and be able to pull them into other projects.
v
As I said, you can publish the toml on itself and use it other projects. You could maybe also publish it as a variant of an existing library. I didn't try that yet, but I think this should also work.
1
But actually, your question has nothing to do with Kotlin and thus is off-topic here. 😉
z
Im not sure I understand what you mean by publishing it - I get that I can publish a library with a toml file, but how would I reference the versions, etc, from other projects that then depend on the toml library? Is #gradle not the right place for questions like this? 😃
v
Nope, see the channel and server subject
As long as your question is not about using Kotlin DSL, or using the Kotlin Gradle Plugin, it is most probably off-topic
But here you find how to consume a properly published version catalog: https://docs.gradle.org/current/userguide/platforms.html#sec:importing-published-catalog
And right above one way how to publish one
z
Ah.. thanks, good to know for the future! Ill check out your link and show myself out homer disappear Fwiw, I also found this which seems to cover the same subject!
👌 1
m
There exists exists an "everything" published catalog 😄 : https://github.com/jamesward/kotlin-universe-catalog
🤯 1
v
That's not exactly a published toml though, but a settings plugin declaring the catalog, isn't it? 🙂
m
Yes, I think so. Also it's nowhere near complete, a.k.a it's manual inclusion. BUt' it's a cool experiment
o
while it's a little off-top for Kotlin slack, it's really a useful thing for libraries with a lot of different modules, so users can easily add all dependencies here is an example from my side on how to create and use version catalog published to maven central: • configuration: https://github.com/whyoleg/cryptography-kotlin/blob/main/cryptography-version-catalog/build.gradle.kts • a little docs: https://whyoleg.github.io/cryptography-kotlin/gradle-version-catalog/ • example of usage in
example
project: https://github.com/whyoleg/cryptography-kotlin/blob/main/tests-publication/build.gradle.kts
z
100% agreed. ive typically copied these between projects in the past, and while that works fine between a few projects.. its a hassle nowadays 😃 besides, really loving the consistency and never having to guess if its libs.kotlinx.coroutines or libs.coroutines, etc. also great in combination with convention plugins across projects, which is ultimately what led me down this rabbit hole!
👌🏾 1
👌 1
h
Well, the settings plugin creates a toml file under the hood which will be published.