我想build.gradle.kts
使用gradle 5.3.1引入的预编译脚本插件功能来模块化我的文件。
当我直接hello-world.gradle.kts
放入简单文件时,它可以正常工作buildSrc/src/main/kotlin
tasks.register("hello-world") { println("hello world") }
并将其包含在我的main的plugins部分中build.gradle.kts
:
plugins {
`hello-world`
}
我现在可以使用gradle hello-world
并查看预期的输出。
但是当我将相同的脚本放入buildSrc/src/main/kotlin/custom/hello-world-custom.gradle.kts
(添加package custom
到脚本中)时,它失败了,尽管文档指出:
同样,只要src / main / kotlin / my / java-library-convention.gradle.kts的软件包声明为my,其插件ID为my.java-library-convention。
主要build.gradle.kts
:
plugins {
`custom.hello-world-custom`
}
但相反,我得到一个错误:
Script compilation error:
Line 3: `custom.hello-world-custom`
^ Unresolved reference: `custom.hello-world-custom`
任何想法如何解决这一问题?
更新:为重现此内容,我创建了一个带有不同“ Hello World”任务的小型存储库。
从文档中还不清楚,但是我找到了解决方案:
必须在反引号之外定义软件包:
plugins {
`hello-world`
custom.`hello-world-custom`
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句