Heyho, I migrated a huge multi-module project to u...
# community-support
b
Heyho, I migrated a huge multi-module project to use convention plugins to share buildLogic. This worked flawlessly and I love convention plugins now. I've placed them in an included build
build-conventions
. Before that, when I was still playing around with them, I had convention plugins in
buildSrc
. With
TYPESAFE_PROJECT_ACCESSORS
enabled, there were even accessors created for the convention plugins. This is not the case, when the plugins lay in
build-conventions
. I now tried to move the plugins to
buildSrc
. Unfortunately, I cannot compile the plugins. I am using one convention plugin in another. This "base" plugin cannot be found. I have questions: • Is it a good idea to have a "base" plugin? • Is it okay to use one convention plugin in another? If so, what am I doing wrong in buildSrc?
a
Is it a good idea to have a "base" plugin?
Yes, although make sure it has a different ID to the standard Gradle base plugin
Is it okay to use one convention plugin in another?
It's encouraged!
If so, what am I doing wrong in buildSrc?
Can you double check the plugin IDs you're using? This always used to trip me up. If you have a file
buildSrc/src/main/kotlin/my-convention.gradle.kts
, and the plugin has
package x.y.z
, then the plugin ID will be
x.y.z.my-convention
.
b
That's it! In my
build-conventions
they didn't had a package.
Thank you 🙂
v
> With
TYPESAFE_PROJECT_ACCESSORS
enabled, there were even accessors created for the convention plugins. That has nothing to do with each other. The point is, that if the plugins are in the classpath, you get those accessors, no matter whether the plugin is implemented using precompiled script plugins, or normal classes, or whatever. One of the subtle differences between
buildSrc
and an included build is, that
buildSrc
is put via parent class loader to the classpath of each and every build script and so if you change anything, everything is out-of-date. With an included build, using the plugin via ID in the
plugins
block adds it to the classpath of that build script and only there things get out of date if something changes. But that of course means, you do not have the accessors. If you would for example also have a settings plugin and that way bring the plugins to classpath of all build scripts similar to when using
buildSrc
, you would also get the accessors.
b
Understood. Thank you, Björn!