当gradle 5预编译脚本插件在包中时,如何让它开始工作

当gradle 5预编译脚本插件在包中时,如何让它开始工作,gradle,Gradle,我想通过使用gradle 5.3.1引入的功能模块化我的build.gradle.kts文件 当我在buildSrc/src/main/kotlin中直接使用我的简单hello world.gradle.kts文件时,它工作得很好 tasks.register("hello-world") { println("hello world") } 并将其包含在我的主build.gradle.kts的插件部分: plugins { `hello-world` } plugins { `

我想通过使用gradle 5.3.1引入的功能模块化我的
build.gradle.kts
文件

当我在
buildSrc/src/main/kotlin
中直接使用我的简单
hello world.gradle.kts
文件时,它工作得很好

tasks.register("hello-world") { println("hello world") }
并将其包含在我的主
build.gradle.kts
的插件部分:

plugins {
   `hello-world`
}
plugins {
   `custom.hello-world-custom`
}
我现在可以使用
gradlehelloworld
查看预期的输出

但是,当我将相同的脚本放入
buildSrc/src/main/kotlin/custom/hello-world-custom.gradle.kts
(将
package-custom
添加到脚本中)时,它失败了,尽管文档说明:

类似地,src/main/kotlin/my/java-library-convention.gradle.kts将生成一个插件ID my.java-library-convention,只要它的包声明为my

build.gradle.kts

plugins {
   `hello-world`
}
plugins {
   `custom.hello-world-custom`
}
但是,我得到了一个错误:

 Script compilation error:

  Line 3:   `custom.hello-world-custom`
        ^ Unresolved reference: `custom.hello-world-custom`
有没有办法解决这个问题


更新:为了重现这一点,我用不同的“hello world”任务创建了一个新的解决方案。

从文档中看不太清楚,但我找到了解决方案:

包必须在backticks之外定义:

plugins {
 `hello-world`
 custom.`hello-world-custom`
}