super minor nitpick/clarification: a convention plugin can be a regular class that implements
Plugin<Project>
,
or a
pre-compiled script plugin.
Either work fine, but pre-compiled script plugins are nice because they look more like regular
.gradle.kts
files.
The quick-guide for creating convention plugins is:
1. create a
./buildSrc dir
2. in
./buildSrc/build.gradle.kts
make sure to apply the
kotlin-dsl plugin
3. also in
./buildSrc/build.gradle.kts
add the Gradle plugins you want to use in conventions. Make sure to use the
Maven coordinates (not the plugin ID) as implementation-dependencies.
4. Create a convention plugin in
./buildSrc/src/main/kotlin/my-convention.gradle.kts
5. in any subproject you can use your convention plugin in the plugins block with
id("my-convention")