我试图使用IntelliJ作为编辑器,使用 gradle-script-kotlin
自动化复杂的构建过程。按照a previous question中的建议,一位同事在build.gradle.kts
文件中突出显示了正确的语法,但是,由于其复杂性,我尝试使用apply from示例将其拆分为多个较小的文件:
apply {
for (script in otherKotlinScripts)
from("buildscripts/$script.kts")
}
las,完成似乎只对
build.gradle.kts
有效。在其他kotlin脚本文件上,自由函数和我的import
都可以正常工作,但是特定于gradle的事情(例如task
闭包):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.
}
有没有办法允许intellij将包含的文件检测为gradle脚本?
最佳答案
原来我没有使用正确的文件名。撰写本文时,kotlin intellij插件的当前版本似乎可以正确完成所有以.gradle.kts
结尾的文件。我包含的文件仅具有.kts
扩展名,而没有.gradle.
关于intellij-idea - 包含的Gradle脚本Kotlin文件的IntelliJ自动补全,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41787686/