I have a Gradle Kotlin project where I define dependencies using an object for versioning, like so:
object Versions {
const val MICROMETER = "1.11.5"
}
dependencies {
implementation("io.micrometer:micrometer-core:${Versions.MICROMETER}")
}
I've noticed that the dependent bot doesn't automatically upgrade or raise a pull request to update to the new version when a new version of the dependency is available. Interestingly, when I simplify the setup without using the object for versioning, as shown below:
dependencies {
implementation("io.micrometer:micrometer-core:1.11.5")
}
The dependent bot does raise a pull request for upgrading to the new version.
Is there a specific configuration or setting I'm missing in my Gradle Kotlin project that would enable the dependentbot to automatically upgrade dependencies when using an object for versioning?
Not directly, but you can use version catalogs.
Create a libs.versions.toml
file in your gradle
folder (where the gradle wrapper files are). And declare your versions and dependencies in that file.
[versions]
micrometer = "1.11.5"
[libraries]
micrometer-core = { module = "io.micrometer:micrometer-core", version.ref = "micrometer " }
And use it like this
dependencies {
implementation(libs.micrometer.core)
}