I'm trying to use gradle-script-kotlin
to automate a complicated build process, using IntelliJ as an editor. Following the advice found in a previous question , a colleague has gotten proper syntax highlighting in the build.gradle.kts
file, however, because of its complexity, I'm trying to split it up into a number of smaller files using the apply from example:
apply {
for (script in otherKotlinScripts)
from("buildscripts/$script.kts")
}
Alas, the completion only seems to actually work on build.gradle.kts
. On other kotlin-script files, free functions and anything that I import
work just fine, but gradle-specific things such as this task
closure:
task("foo") {
// intelliJ can't seem to figure out what the receiver is here,
// task itself gets highlighted in red, and its members fail
// to complete.
}
Is there a way to allow intellij to detect included files as gradle scripts?
It turns out that I wasn't using the correct filenames. The current version of the kotlin intellij plugin at time of writing seems to complete correctly any file that ends with .gradle.kts
. My included files just had a .kts
extension without the .gradle.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.