Build System & Convention Plugins
Relevant source files
The following files were used as context for generating this wiki page:- build-logic/convention/src/main/kotlin/AndroidApplicationConventionPlugin.kt
- build-logic/convention/src/main/kotlin/AndroidLibraryConventionPlugin.kt
- build-logic/convention/src/main/kotlin/ProjectConventionPlugin.kt
- gradle/libs.versions.toml
- build-logic/convention/src/main/kotlin/com/vocabri/SpotlessConfiguration.kt
- build-logic/convention/src/main/kotlin/com/vocabri/DetektConfiguration.kt
- build-logic/convention/src/main/kotlin/com/vocabri/KoverConfiguration.kt
- build-logic/convention/src/main/kotlin/com/vocabri/PluginExtensions.kt
- build-logic/convention/src/main/kotlin/com/vocabri/CommonExtensions.kt
- build-logic/convention/src/main/kotlin/com/vocabri/JvmVersionConfig.kt
The Vocabri project utilizes a Gradle-based build system with custom convention plugins to enforce consistency and streamline configuration across its various modules. Located in the build-logic directory, these plugins centralize settings for Android application and library modules, as well as project-wide tools for code formatting (Spotless), static analysis (Detekt), and code coverage (Kover). This approach promotes maintainability by abstracting common build configurations into reusable components.
Dependency management is handled through a Gradle version catalog (libs.versions.toml), which provides a single source of truth for library versions, plugins, and coordinates. This ensures that all modules use consistent dependency versions and simplifies the process of updating them.
Convention Plugins Overview
The core of the build system is a set of convention plugins that apply specific configurations based on the module type.
| Plugin | Description | Source File |
|---|---|---|
ProjectConventionPlugin | Applied to the root project to configure project-wide quality tools: Spotless, Detekt, and Kover. | ProjectConventionPlugin.kt:28-35 |
AndroidApplicationConventionPlugin | Applied to Android application modules (:app). It applies the com.android.application and common Kotlin Android plugins. | AndroidApplicationConventionPlugin.kt:28-34 |
AndroidLibraryConventionPlugin | Applied to Android library modules (e.g., :data, :domain). It applies the com.android.library and common Kotlin Android plugins. | AndroidLibraryConventionPlugin.kt:28-34 |
KoverConventionPlugin | A dedicated plugin to apply Kover configuration. | KoverConventionPlugin.kt:28-33 |
Plugin Application Flow
This diagram illustrates how the convention plugins apply configurations to different parts of the project.
Code Quality and Formatting
The project enforces strict code quality standards through Spotless, Detekt, and Kover, which are configured and applied via the ProjectConventionPlugin.
Spotless (Code Formatting)
Spotless is configured via the applySpotless extension function to format a wide range of file types. It ensures consistent styling, whitespace, and license headers across the codebase.
Sources: com/vocabri/SpotlessConfiguration.kt
Configuration Details:
| Format | Target Files | Rules Applied - - |
| misc | **/*.gradle, **/*.md, **/.gitignore | leadingTabsToSpaces, trimTrailingWhitespace, endWithNewline - |
| kotlin | **/*.kt | ktlint with max_line_length of 120, license header from .spotless/license-kt, excludes build directories. - |
| kts | **/*.kts | License header from .spotless/license-kt, excludes build directories. - - |
| xml | **/*.xml | License header from .spotless/license-xml, excludes build and IDE directories. - |
| json | **/*.json | Default JSON formatting, excludes build directories. - |
| yaml | **/*.yml, **/*.yaml | Default YAML formatting, excludes build directories. - |
Detekt (Static Analysis)
Detekt is configured to perform static code analysis on all subprojects, using a shared configuration file and custom rules for Jetpack Compose.
Sources: com/vocabri/DetektConfiguration.kt
Key Configurations:
- Configuration File: Uses a root-level config file at
/.detekt/detekt-config.yml. - Auto-Correction:
autoCorrectis enabled. - Parallel Execution:
parallelis enabled for faster analysis. - Compose Rules: The
detekt.compose.ruleslibrary is added as adetektPluginsdependency. - JVM Target: The JVM target is set to
21. - Reports: Generates XML and HTML reports in the
build/reports/detekt/directory of each module.
// build-logic/convention/src/main/kotlin/com/vocabri/DetektConfiguration.kt:43-47
configure<DetektExtension> {
buildUponDefaultConfig = true
autoCorrect = true
parallel = true
config.setFrom(
files("$rootDir/.detekt/detekt-config.yml"),
)
}
Sources: com/vocabri/DetektConfiguration.kt:43-49
Kover (Code Coverage)
Kover is used for measuring code coverage and is configured with extensive exclusion rules to provide more accurate and meaningful reports.
Sources: com/vocabri/KoverConfiguration.kt
The following diagram shows the logic for Kover's coverage exclusions.
This diagram shows the categories of code excluded from Kover's coverage reports.
Sources: com/vocabri/KoverConfiguration.kt:44-63
Dependency Management
The project uses a Gradle Version Catalog (gradle/libs.versions.toml) to manage all dependencies and plugin versions. This centralizes version definitions and makes dependency declarations more readable.
Sources: gradle/libs.versions.toml
Key Versions
| Component | Version |
|---|---|
android-compileSdk | 36 |
android-minSdk | 24 |
kotlin | 2.2.21 |
android-gradle-plugin | 8.13.0 |
detekt | 1.23.8 |
kover | 0.9.3 |
spotless | 8.0.0 |
compose-bom | 2025.10.01 |
sqldelight | 2.1.0 |
Sources: gradle/libs.versions.toml:2-20
libs Extension
A custom extension property, libs, is defined to provide convenient, type-safe access to the version catalog from build scripts.
// build-logic/convention/src/main/kotlin/com/vocabri/CommonExtensions.kt
val Project.libs: VersionCatalog
get() = extensions.getByType<VersionCatalogsExtension>().named("libs")
Sources: com/vocabri/CommonExtensions.kt:27-29
Summary
The build system for Vocabri is built upon a solid foundation of Gradle convention plugins and a version catalog. This structure standardizes configurations for Android modules, enforces high code quality through integrated tools like Spotless and Detekt, and provides meaningful code coverage reports with Kover. By centralizing these configurations in the build-logic module, the project ensures consistency, reduces boilerplate in module-level build.gradle.kts files, and simplifies overall maintenance and dependency updates.