gpt4 book ai didi

gradle - 当 gradle 5 预编译脚本插件位于包中时,如何才能使其正常工作

转载 作者:行者123 更新时间:2023-12-02 06:30:13 24 4
gpt4 key购买 nike

我想使用 precompiled script plugins 模块化我的 build.gradle.kts 文件gradle 5.3.1 引入的功能。

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

tasks.register("hello-world") { println("hello world") }

并将其包含在我的主 build.gradle.kts 的插件部分中:

plugins {
`hello-world`
}

我现在可以使用 gradle hello-world 并查看预期的输出。

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

Likewise, src/main/kotlin/my/java-library-convention.gradle.kts would result in a plugin ID of my.java-library-convention as long as it has a package declaration of my.

主要的build.gradle.kts:

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

但是,我收到一个错误:

 Script compilation error:

Line 3: `custom.hello-world-custom`
^ Unresolved reference: `custom.hello-world-custom`

有什么想法可以解决这个问题吗?

更新:为了重现这一点,我创建了一个 small repo具有不同的“hello world”任务。

最佳答案

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

包必须在反引号之外定义:

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

关于gradle - 当 gradle 5 预编译脚本插件位于包中时,如何才能使其正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55847469/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com