I started to migrate groovy gradle scripts to kotlin dsl and didn't encounter any problem with build.gradle and settings.gradle files. I have several scripts that i apply in build.gradle.kts. When i change these scripts to kotlin dsl, android studio shows "Code insight unavailable (scripts configuration wasn't received.)" message and yet scripts are still working.
I have scripts directory under root project and this is how i apply in build.gradle.kts:
apply(from = "../scripts/ktlint.gradle.kts")
Example script file :
val ktlint by configurations.creating
tasks.register<JavaExec>("ktlint") {
description = "Check Kotlin code style."
main = "com.pinterest.ktlint.Main"
classpath = ktlint
args = listOf("src/**/*.kt")
}
tasks.register<JavaExec>("ktlintFormat") {
description = "Fix Kotlin code style deviations."
main = "com.pinterest.ktlint.Main"
classpath = ktlint
args = listOf("-F", "src/**/*.kt")
}
dependencies {
ktlint(libs.ktlint)
}
I tried to move scripts directory to under app module and buildSrc but the warning didn't resolve. Appreciate any help.
Problem is solved, it's because my buildSrc implementation was wrong. This topic helped me a lot.