Is there a way to apply convention plugins in the root build.gradle.kts without publishing them first?

I am building a Gradle project containing multiple convention plugins and using Sharing build logic in a multi-repo setup Sample as inspiration.

Publishing those convention plugins and using them in different projects is working fine. But when I want to apply one of those convention plugins in the root build.gradle.kts, I have to first publish that convention plugin and then include it like a regular plugin.

My project structure is as follows:

convention-plugins
├── build.gradle.kts
├── settings.gradle.kts
├── src
│   ├── main
│   │   └── kotlin
│   │       └── some.package
│   │           ├── publishing.gradle.kts
│   │           └── download-git-hooks.gradle.kts

When I want to apply one of those plugins, I first have to publish the plugin (for example with publishToMavenLocal). I can then use the plugin in the plugins-block:

plugins {
    id("some.package.publishing") version("1.0.0-SNAPSHOT")
    id("some.package.download-git-hooks") version("1.0.0-SNAPSHOT")
}

Having to publish a plugin before being able to use it in the root build.gradle.kts is quite tedious and suboptimal.
Is there a way to apply those convention plugins without having to publish them first?

You mean in convention-plugins/build.gradle.kts?
This can of course not work, this is a classical chicken-and-egg situation.
You need the plugin ready-made to apply it to the build to build the plugin.
You need to build the plugin to apply it to the build.
But to build the plugin you need to apply the plugin to the build.
See where that goes?

In the plugin project itself, you can always just use the last published version of itself.

Yes, that’s what I mean. I was half expecting it wouldn’t work because of something like that.
Thank you for the clarification!

1 Like