21

I want to migrate from Groovy to Kotlin DSL in my gradle build script. I have 2 scripts in the project: build.gradle and publish-maven.gradle which is attached in the first one.

For Groovy I apply the script like that:

apply from: "${rootProject.projectDir}/publish-maven.gradle"

For Kotlin, I found the same code will look like that:

apply(from = "publish-maven.gradle.kts")

But publish-maven.gradle.kts isn't attached to build.gradle.kts. At the top of the script the IDE constantly shows warning:

Code insight unavailable (configuration for this script wasn't received during the last Gradle project import)

and Kotlin syntax isn't recognised.

I also tried

apply(from = "${rootProject.projectDir}/publish-maven.gradle.kts")

or have found other examples but non of them helped.

What do I have to do to apply this script? Or the general question is how can I split build script into several files?

Gradle version: 6.7; JDK: 1.8; IDE: IntellijIdea

4
  • Any success? I have the same problem. Commented Feb 4, 2021 at 8:57
  • Unfortunately, no. I decided not to split build script into several files. Commented Feb 5, 2021 at 13:33
  • It's probably not supported. This seems related github.com/gradle/kotlin-dsl-samples/issues/1287 Commented Feb 5, 2021 at 17:07
  • Can you add the code for build.gradle file in which you imported the other script file? Commented Jun 6, 2021 at 13:39

1 Answer 1

9

In my case, a fix for "Code insight unavailable" message in Intellij was to add references to my subprojects in settings.gradle.kts file.

I've tried to set a Gradle project with two subprojects: "app" and "core". I didn't follow the examples correctly and I didn't include references in settings.gradle.kts.

settings.gradle.kts

rootProject.name = "MyProject"

include("app", "core") // <-- Line added

After reloading the Gradle project in the IDE, everything was fine.

While I might not be answering your question specifically (I'm sorry for that), this is one of very few results for searching "Code insight unavailable" in the search engine, so I hope someone will find this answer useful.

Sign up to request clarification or add additional context in comments.

1 Comment

The error "Code insight unavailable" never went away for us, after successfully migrating from Groovy to Kotlin DSL. What ended up fixing the problem was removing the reference to mavenLocal() (it was no longer used) in the root build.gradle.kts file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.