5

I have converted my Gradle build scripts to the Kotlin DSL. Since I was starting with a small new project, everything went according to plan. When referencing more and more dependencies I wanted to put their version numbers in the script as constants, especially for those versions which are used in several places.

In my app/build.gradle.kts I have basically the following:

dependencies {
    implementation("androidx.appcompat:appcompat:1.0.0")
    ...
}

Android Studio inspections tell me, that I should upgrade to 1.1.0. I changed it to

val appCompat = "1.0.0"
dependencies {
    implementation("androidx.appcompat:appcompat:$appCompat")
    ...
}

but now I do not get that inspection hint anymore.

I compared my Kotlin script to what I find in the Sunflower reference project and found it to be working there. So, I experimented with defining extra-values with

extra.apply {
    set("appCompat", "1.0.0")
}
implementation("androidx.appcompat:appcompat:${extra["appCompat"]}")

but got no inspection hint either.

To me, it seems that the inspection is broken using the Kotlin DSL. Do you agree or do you have a working setup for this?

ceedee
  • 371
  • 1
  • 11

1 Answers1

2

In my environment inspection is broken also. So I used from third-party plugin and run it task in some interval for checking available update and manage it.

More details: https://github.com/jmfayard/gradle-dependencies-plugins

Naruto Uzumaki
  • 2,019
  • 18
  • 37