Multimodule gradle repository with plugins

Hello. I’m trying to build a plugin for my own usage, but I’m stuck with the repository structure.

I’m using buildSrc with a single kotlin-conventions.gradle.kts build convention. Using this convention, I’m building a plugin:

kotlin
plugins {
    id("kotlin-conventions")
    id("java-gradle-plugin")
}

dependencies {
    // ...
}

gradlePlugin {
    plugins {
        create("io.kloak.cqrs.plugin") {
            id = "io.kloak.cqrs.plugin"
            implementationClass = "io.kloak.cqrs.plugin.KloakCqrsPlugin"
        }
    }
}

Now I’m trying to apply this plugin to another module, but I’m stuck. How can I do it?

a) If I use includeBuild, I can’t use kotlin-conventions. I think Gradle follows the plugin → buildSrc build path, but I need the other way around.
b) I could publish my plugin to Maven Local on each build and use it from ~/.m2, but I don’t like this approach
c) I don’t want to include this plugin to buildSrc because it is not build logic, it just part of library I’m trying to make, but It could work

Are there other alternatives?

You can find code here: GitHub - novikmisha/kloak
Plugin im trying to apply is located here: kloak/kloak-cqrs/kloak-cqrs-plugin at master · novikmisha/kloak · GitHub
And I want to apply plugin to this module:
kloak/kloak-cqrs/example at master · novikmisha/kloak · GitHub

That’s a chicken and egg situation.
To execute a build you must configure it,
to configure it you need the plugins built,
to build the plugin you need to execute the build.

A composite build (using includeBuild) is indeed the way to go.
What you did not realize is, that the included build is a full standalone build with its own buildSrc and every build can only use its own buildSrc.

But I guess you want to use that convention plugin also in the other projects, so then don’t use buildSrc at all, but move that convention plugin into yet another build that you include from both of the other two.

upd.

But I guess you want to use that convention plugin also in the other projects, so then don’t use buildSrc at all, but move that convention plugin into yet another build that you include from both of the other two.

Thx, I think I got it. A rather complex build for such a simple problem turned out.