0
0
mirror of https://github.com/thunderbird/thunderbird-android.git synced 2024-09-19 19:52:14 +02:00
thunderbird-android/build-plugin
2024-08-15 12:36:34 +02:00
..
src/main/kotlin Bump Android Gradle Plugin 8.2.2 -> 8.5.2 and Android Tools 31.2.2 -> 31.5.2 2024-08-15 12:36:34 +02:00
build.gradle.kts Bump Kotlin 1.9.24 -> 2.0.0 and switch to the compose compiler plugin 2024-06-14 16:11:28 +02:00
README.md Fix markdown indent issues 2024-01-16 16:46:09 +01:00
settings.gradle.kts Add build-plugin 2023-02-14 10:41:09 +01:00

Build plugins

The build-plugin folder defines Gradle build plugins, used as single source of truth for the project configuration. This helps to avoid duplicated build script setups and provides a central location for all common build logic.

Background

We use Gradle's sharing build logic in a multi-repo setup to create common configuration. It allows usage of xyz.gradle.kts files, that are then automatically converted to Gradle Plugins.

The build-plugin is used as included build in the root settings.gradle.kts and provides all included xyz.gradle.kts as plugins under their xyz name to the whole project.

The plugins should try to accomplish single responsibility and leave one-off configuration to the module's build.gradle.kts.

Convention plugins

  • thunderbird.app.android - Configures common options for Android apps
  • thunderbird.app.android.compose - Configures common options for Jetpack Compose, based on thunderbird.app.android
  • thunderbird.library.android - Configures common options for Android libraries
  • thunderbird.library.android.compose - Configures common options for Jetpack Compose, based on thunderbird.library.android
  • thunderbird.library.jvm - Configures common options for JVM libraries

Supportive plugins

Add new build plugin

Create a thunderbird.xyz.gradle.kts file, while xyz describes the new plugin.

If you need to access dependencies that are not yet defined in build-plugin/build.gradle.kts you have to:

  1. Add the dependency to the version catalog gradle/libs.versions.toml
  2. Then add it to build-plugin/build.gradle.kts.
    1. In case of a plugin dependency use implementation(plugin(libs.plugins.YOUR_PLUGIN_DEPENDENCY)).
    2. Otherwise implementation(libs.YOUR_DEPENDENCY)).

When done, add the plugin to build-plugin/src/main/kotlin/ThunderbirdPlugins.kt

Then apply the plugin to any subproject it should be used with:

plugins {
    id(ThunderbirdPlugins.xyz)
}

If the plugin is meant for the root build.gradle.kts, you can't use ThunderbirdPlugins, as it's not available to the plugins block. Instead use:

plugins {
    id("thunderbird.xyz")
}

Acknowledgments