Reputation: 11993
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") }
and include it in the plugins section of my main build.gradle.kts
:
plugins {
`hello-world`
}
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`
}
but instead, I get an error:
Script compilation error:
Line 3: `custom.hello-world-custom`
^ Unresolved reference: `custom.hello-world-custom`
Any ideas how to fix this?
Update: to reproduce this, I created a small repo with different "hello world" tasks.
Upvotes: 5
Views: 537
Reputation: 11993
It was not quite clear from the docs, but I found the solution:
The package has to be defined outside the backticks:
plugins {
`hello-world`
custom.`hello-world-custom`
}
Upvotes: 4