I want to modularize my build.gradle.kts files by using the precompiled script plugins feature introduced with gradle 5.3.1.
It works fine when I have my simple hello-world.gradle.kts file in buildSrc/src/main/kotlin directly
tasks.register("hello-world") { println("hello world") }
Run Code Online (Sandbox Code Playgroud)
and include it in the plugins section of my main build.gradle.kts:
plugins {
`hello-world`
}
Run Code Online (Sandbox Code Playgroud)
I can now use gradle hello-world and see the expected output.
But when I place the same script in buildSrc/src/main/kotlin/custom/hello-world-custom.gradle.kts (adding package custom to the script) it fails, although the documentation states:
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.
The main build.gradle.kts:
plugins {
`custom.hello-world-custom`
}
Run Code Online (Sandbox Code Playgroud)
but instead, I get an error:
Script compilation error:
Line 3: `custom.hello-world-custom`
^ Unresolved reference: `custom.hello-world-custom`
Run Code Online (Sandbox Code Playgroud)
Any ideas how to fix this?
Update: to reproduce this, I created a small repo with different "hello world" tasks.
文档中不太清楚,但我找到了解决方案:
包必须在反引号之外定义:
plugins {
`hello-world`
custom.`hello-world-custom`
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
476 次 |
| 最近记录: |