Integrating Kotlin Code into the Gradle Build Process
summary
Example builds Kotlin source from JSON design tokens, registers a Gradle task that runs before Kotlin compilation and writes files into build/generated/source so the compiler picks them up, optionally moved into a reusable Gradle plugin stored outside buildSrc with an extension for configuration and compatible with the configuration cache. Uses KotlinPoet codegen or string templates, runs a unit contrast ratio test (threshold 3) in CI, powers ~70 BMW apps, and the end‑to‑end flow validates in PRs.
AI-written summary · about
chapters (11)
- 0:00Introduction
- 1:47Automate code generation for themes
- 3:40Gradle task in build.gradle
- 6:33Improving tasks with buildSrc
- 9:29Generate design tokens from JSON
- 10:50Validating colors with tests
- 12:58BMW theming in production
- 14:46Packaging as Gradle plugin
- 17:14Code generation libraries
- 19:20AI for theme generation
- 20:49Summary
related talks
39mKotlinify your Gradle
40mBetter Android Development with Kotlin & Gradle
48mType-Safe Build Logic with Gradle Kotlin DSL
38mKSP and Plugins. Optimizing Kotlin Multiplatform common code
37mGenerating Kotlin Code
22mUse Kotlin DSLs for your Gradle scripts
42mRock the Gradle, rule the world
34mGradle scripts in Kotlin: is it cool?
