Menu

Gradle convention plugins for a multi-module Android app: build-logic, AGP 9 and the version catalog
πŸ“°

Gradle convention plugins for a multi-module Android app: build-logic, AGP 9 and the version catalog

DEV Community: androidΒ·Charles HartmannΒ·7 days ago
#S5HIpv6j
#devtoandroid#devto#dev#plugin#android
Reading 0:00
15s threshold

Once an Android app has a dozen or more modules, every build.gradle.kts starts to repeat the same twenty lines: the Android plugin, compileSdk , minSdk , Java and Kotlin options, the Compose setup, the Hilt plugin and processor, the test dependencies. Bumping minSdk means editing every file, and forgetting one means a module that quietly builds differently from the rest.

Convention plugins fix that. A convention plugin is a small Gradle plugin you write yourself, which applies and configures other plugins the way your project wants. Each module then says what kind of module it is, a library or a feature, and the plugin supplies the how . Google's Now in Android sample is built this way, and Gradle's documentation recommends this approach over cross-project configuration with subprojects {} and allprojects {} .

buildSrc or build-logic

Gradle offers two places for shared build logic.

buildSrc is a special directory Gradle builds automatically before your project.…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.