Gradle + Idea = Script dependencies resolution failed
Every time I load Gradle project (Kotlin DSL), Idea cannot resolve dependencies and the whole script is red, full of errors, but the script itself is OK. I tried everything - cache invalidation, multiple restarts, refresh, even multiple IDEA versions on different machines with different OS and the result is always the same... nothing works. Sometimes it magically starts working, but the next day I start Idea it is again full of errors. Does anyone have a similar issue? I don't know what to do and how to fix it. I use Linux most of the time and macOS. I tried several versions of Gradle (including the newest of course).
When I run build from right side Gradle panel build is successful:
BUILD SUCCESSFUL in 0s
8 actionable tasks: 8 executed
When I open any of gradle kts scripts I got a yellow warning on the top with a message:
Script dependencies resolution failed, using previous dependencies
auto-import on or off - no difference.
EDIT:
I think I know where the problem is. I usually have opened/imported multiple gradle projects in one Intellij IDEA instance/window and if other projects have an older version of Gradle wrapper, the older version of gradle is used even for projects that have newer wrapper version specified. IDEA tries to process Kotlin DSL build script with incorrect gradle version.
Logs:
2019-06-29T19:00:20.890+0200 - ResolutionFailure(
scriptFile = /home/toby/WORKSPACE/2n/projects/my2n-libs/build.gradle.kts,
failure = org.gradle.tooling.BuildException: Could not fetch model of type 'KotlinBuildScriptModel' using Gradle installation '/home/toby/.gradle/wrapper/dists/gradle-4.9-all/491wbe0x5d54n9cojs2p0zv90/gradle-4.9'.
but project has defined newer version of gradle wrapper:
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip
It seems like incorrect behavior to me.
Please sign in to leave a comment.
Please follow this issue for updates: https://youtrack.jetbrains.com/issue/KT-32357