Latest Gradle version, 7.0, introduced a feature of central declaration of dependencies. You can now declare your dependencies (versions, libraries or even sets of related libraries - bundles) in a separate file and use them across whole, even multi-module, project:
# libs.versions.toml
[versions]
kotlin = "1.4.32"
tgbotapi = "0.33.3"
[libraries]
tgbotapi-core = { group = "dev.inmo", name = "tgbotapi.core", version.ref = "tgbotapi" }
[bundles]
tgbotapi = ["tgbotapi-core"]
// And then in your build.gradle.kts
dependencies {
implementation(libs.bundles.tgbotapi)
}
However, I cannot make this feature work with the plugins
block:
plugins {
kotlin("jvm").version(libs.versions.kotlin).apply(false) // Unresolved reference: libs
}
How do i use this central declaration for plugins?
You can use
plugins {
alias(libs.your.library) apply false
}
to add plugins. Your Kotlin version notation should also work though. You could also add this to your libs.versions.toml:
[plugins]
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
and then:
plugins {
alias(libs.plugins.kotlin.jvm) apply false
}