How do I include a convention plugin from build-lo...
# community-support
b
How do I include a convention plugin from build-logic/src/main/kotlin/my-conventions.kts ? Using
Copy code
id("build-logic.my-conventions")
throws * Exception is: org.gradle.api.plugins.UnknownPluginException: Plugin [id: 'build-logic.my-conventions'] was not found in any of the following sources:
1
v
Your plugin ID is
my-conventions
.
Which actually is bad practice, as ones without namespace (dot in name) should stay reserved for built-in plugins.
Add a
package
statement in the script or rename the file accordingly
b
thank you
👌 1
Follow up: in build-logic/build.gradle.kts I can use
Copy code
alias(libs.plugins.versions)
but not in the convention plugin in build-logic/src/main/kotlin/my-conventions.kts
do I need another settings.gradle.kts?
v
No, you add the plugin as dependency in the build script of
build-logic
and in the convention plugin just apply using the plain ID
b
all these build script exceptions drive me nuts 🙂
there's no way to turn a plugin spec in libs.versions.toml into a dependency instead, correct?
like,
Copy code
dependencies {
 implementation(libs.plugins.versions)
}
v
Not yet unfortunately. github.com/gradle/gradle/issues/17963 But you can use a helper function like
Copy code
private fun plugin(plugin: Provider<PluginDependency>) = plugin.map {
    "${it.pluginId}:${it.pluginId}.gradle.plugin:${it.version.requiredVersion}"
}
b
thank you