This message was deleted.
# community-support
s
This message was deleted.
c
apply from
is the mechanism to invoke another script.
d
ok thanks, I’ll see if I can find some example f tht
following on from this I discovered that you can create a custom plugin quite easily and this is probably the best way, so I have copied https://github.com/gradle/kotlin-dsl-samples/tree/master/samples/buildSrc-plugin however my project is a multi-module project and I am getting
plugin was not found
errors
c
how are you applying the plugin in your subprojects?
d
normally I use apply because the plugin is declared in the root build file however I am trying to write the plugin within a subproject so I have added plugins:
Copy code
apply(plugin = "kotlin")
apply(plugin = "com.google.cloud.tools.jib")
plugins {
    id("greet")
}
Plugin [id: 'greet'] was not found in any of the following sources:
c
using
plugins
is the correct way to reference it. buildSrc should be at the root of the project to compile and expose that plugin.
*root project - not within a subproject.
d
ok
ok that works thanks. if I want multiple plugins though, do they all have to be defined within
buildSrc
?
it could get a bit messy
c
Yes, the plugins would go in buildSrc (or, alternately, in an includeded ‘build-logic’ project, but the effect is largely the same). Typically you’d have a plugin for each convention - for example, a “java library” always has these settings (JVM version, javadoc settings, etc), and applying those conventions to relevant subprojects.
v
it could get a bit messy
If you already know that, don't do it. I usually never use
buildSrc
nowadays, but always included builds. And you can easily have one build you include per plugin you want to write or group a few in one build or however you like the buildtree to look like.