Search code examples
gradleintellij-ideaandroid-gradle-pluginbuild.gradlegradle-kotlin-dsl

Code insight unavailable (script configuration wasn't received) when create a custom gradle.kts file


I create a sample Kotlin project with Gradle DSL using IntelliJ IDEA and when i create a custom gradle.kts file(named custom.gradle.kts, located at the same level as settings.gradle.kts & build.gradle.kts), IDE prompt code insight unavailable.But the code insight is available in build.gradle.kts and settings.gradle.kts. Although the script can run normally, it is too unfriendly for script writing.

IDEA: enter image description here

custom.gradle.kts enter image description here

settings.gradle.kts enter image description here

build.gradle.kts enter image description here

I tried to invalidate the cache or add to standalone scripts, those are not working for me.


Solution

  • If you want to move some of your Gradle scripting code to another Kotlin script file, you should do it in a precompiled script plugin.

    I wrote an answer explaining exactly how to do this earlier in the year.