I'm having a hard time applying my custom external gradle plugins to an existing multi-module project. My project's structure looks like this:
my-app/
├─ buildSrc/
│ ├─ build.gradle.kts
├─ module1/
│ ├─ build.gradle.kts
├─ module2/
│ ├─ build.gradle.kts
├─ settings.gradle.kts
I've now implemented a couple of custom binary plugins which live in another repository and publishing them to mavenLocal()
like so:
Plugin Repo Code
gradlePlugin {
plugins {
create("plugin") {
id = "organization.gradle.my-conventions"
implementationClass = "organization.gradle.MyConventionsPlugin"
version = "0.0.1"
}
create("plugin2") {
id = "organization.gradle.my-other-conventions"
implementationClass = "organization.gradle.MyOtherConventionsPlugin"
version = "0.0.1"
}
}
}
Main Project Code
In my main project, I've configured settings.gradle.kts
to resolve plugins from mavenLocal
and apply one of the plugins (let's say plugin1) in the build.gradle.kts
of module1. This looks like this:
plugins {
id("organzation.gradle.MyConventionsPlugin") version "0.0.1"
}
This doesn't work though. I end up getting a stacktrace saying:
> Failed to apply plugin class 'org.jetbrains.kotlin.gradle.scripting.internal.ScriptingGradleSubplugin'.
> Cannot run Project.afterEvaluate(Action) when the project is already evaluated.
I tried the same way of applying the plugins in a non multi-module project (i.e. a single build.gradle.kts
) and the plugins are applied as expected. So this most likely has to do with the multi-module aspect of it and some additional config?