Applying a convention plugin from the parent project

I have a multi module project. I have conventions plugins built with kotlin-dsl (included in the root project’s settings via includedBuild("conventions")).

Currently I can apply my convention plugins in subproject in their respective plugins block, e.g.

plugins {

Since I have multiple modules that are java projects, I wanted to apply this convention plugins from the parent project, e.g.

// Do not use projects with TYPESAFE_PROJECT_ACCESSORS here
val javaProjects = subprojects - jmhProjects - nativeProjects

configure(javaProjects) {
  apply(plugin = "")

Unfortunately the build fails because plugin with id ‘’ is not found.

Note sandbox is just my public playground, but portions of the code is in private repositories.

While you could make it work, just don’t.
If you now again use such bad-practice cross-project configuration to apply your convention plugins,
you void some of the major advantages of using convention plugins.

The idiomatic way indeed is to apply the convention plugin in the projects where you want them to be effective directly.
If you have 10 different convention plugins that you want to apply to a set of projects and that is your problem, then make an 11th convention plugin that applies those 10 convention plugins and then apply just that 11th convention plugin to your projects.

OK, thank you very much for the fast answer.
I knew I was walking on the edge there as leveraging conventions plugins in their own subprojects let me avoid to maintain the parent build.
Anyway your answer helped me chose wisely there.

1 Like