This is the simplified version of my Modern Gradle Template that suites for using as a GitHub template.
The structure of the template stays the same but less boiler stuff to be deleted.
This template can be used to create new spring/quarkus/micronaut/etc. projects, or to create new libraries. No matter it is single-module or multi-module, it is easy to start with this template.
Advantages:
- Centralized version management by version catalog
and gradle platform
(together cover any version declaration in the main build script,
and
plugins
anddependencies
blocks in precompiled script plugins, without any hacks) - Composite build, not
buildSrc
(Although it doesn't matter anymore since Gradle 8.0) - Composition over Inheritance using mixin plugins and convention plugins to maximize parallel build performance
- Modify the project name
rootProject.name
insettings.gradle.kts
to your own project name. - Add your own mixin plugins and convention plugins,
if you want to start from scratch, you can delete all preexisting mixin and convention plugins.
Remember to archive centralized version management by adding your
own libraries into the version catalog.
- Tip 1: if you want to use version catalog in the
dependencies
block in precompiled script plugins (mixin or convention plugins), put them in theconstraints
block in thedev-version-constraints
platform. Then in precompiled script plugins, declare the library dependency without the version (e.g.implementation("org.springframework.boot:spring-boot-starter")
). This works for Maven bom and Gradle platform as well. - Tip 2: if you want to use version catalog in the
plugins
block in precompiled script plugins (mixin or convention plugins), you instead let thebuild.gradle.kts
(is also the one withkotlin-dsl
applied) that build the precompiled script plugin applies the version catalog. Then in precompiled script plugins, declare the library dependency without the version ((e.g.id("org.springframework.boot")
) - Tip 3: there is a little
kotlin-jvm
mixin plugin that demonstrates the above two tips.
- Tip 1: if you want to use version catalog in the
- Delete the sample submodules beginning with
sample-
, and start adding your own submodules. Or you can reuse them by renaming them as it only contains a singlebuild.gradle.kts
file. - (Optional) The template contains a renovate bot config file to automatically update dependencies in the version catalog. You can delete it if you don't need it.
- Convert this template to a Cookiecutter template using this guide and this sample template