Upgrade to Pro — share decks privately, control downloads, hide ads and more …

BDD 2024 - Automate Dependency Management in a Scalable Way with Gradle Version Catalog

BDD 2024 - Automate Dependency Management in a Scalable Way with Gradle Version Catalog

Ahmad Arif Faizin

March 09, 2024
Tweet

More Decks by Ahmad Arif Faizin

Other Decks in Programming

Transcript

  1. Baparekraf Developer Day 2024 Automate Dependency Management in a Scalable

    Way with Gradle Version Catalog Ahmad Arif Faizin Curriculum Developer Lead at Dicoding Indonesia
  2. Baparekraf Developer Day 2024 1. The evolution of dependency management

    2. Deep dive to Gradle Version Catalog 3. How to automate dependency update Outline
  3. Baparekraf Developer Day 2024 Dependency Management • Grouping dependency with

    same version to reduce redundancy • Centralizing dependency for multi-module in one place • Easy to upgrade dependency version automatically
  4. Baparekraf Developer Day 2024 🗿Stone Age: Groovy Pros • Been

    used for a long time • Tons of examples • DSL support
  5. Baparekraf Developer Day 2024 🗿Stone Age: Groovy Pros • Been

    used for a long time • Tons of examples • DSL support Cons • Need to learn new language • Manual version management • No code completion • No type safety
  6. Baparekraf Developer Day 2024 🏰Medieval Age: Kotlin DSL (KTS) Pros

    • DSL support • No need to learn new language (one language for all!) • Code completion • Access to documentation • Can be mixed with Groovy DSL
  7. Baparekraf Developer Day 2024 💫Convert Groovy to Kotlin DSL •

    Rename file extensions build.gradle jadi build.gradle.kts • Add = to assignment calls minSdk 24 jadi minSdk = 24 • Prefix boolean properties with is minifyEnabled true jadi isMinifyEnabled = true • Add parentheses to method calls include ':app' jadi include(":app") • Convert strings testImplementation 'junit:junit:4.13.2' jadi testImplementation("junit:junit:4.13.2")
  8. Baparekraf Developer Day 2024 🏰Medieval Age: Kotlin DSL (KTS) Pros

    • DSL support • No need to learn new language (one language for all!) • Code completion • Access to documentation • Can be mixed with Groovy DSL Cons • Minim of examples • Tend to be slower
  9. Baparekraf Developer Day 2024 🏭Industrial Age: Kotlin DSL + buildSrc

    Pros • Code completion • Type safety • IDE Support for navigation
  10. Baparekraf Developer Day 2024 buildSrc Setup • Create a new

    directory “buildSrc” • Create build.gradle.kts inside it • Create const for all dependencies
  11. Baparekraf Developer Day 2024 🏭Industrial Age: Kotlin DSL + buildSrc

    Pros • Code completion • Type safety • IDE Support for navigation Cons • Non trivial setup • Frequent cache loss (version update clear the cache) • No warning for dependency update
  12. Baparekraf Developer Day 2024 🏙Modern Age: Gradle Version Catalog Pros

    • Code completion • Type safety • No cache loss • Best practices and easy to setup • Android Studio support • 1 line implementation via bundles • Auto dependency update • Publish catalog to other project!
  13. Baparekraf Developer Day 2024 1. Dependency management is useful for

    centralizing dependency version and avoiding bug 2. Gradle Version Catalog is the future of dependency management for Android 3. We can automate dependency version update using Dependabot easily Summary
  14. Baparekraf Developer Day 2024 References • Migrate to Gradle version

    catalog and convention plugins - DevFest Triveneto 2022 • Groovy for Java Developers • Android Developers Blog: Kotlin DSL is Now the Default for New Gradle Builds • Migrate your build configuration from Groovy to Kotlin | Android Studio • Dependency Management with buildSrc and Kotlin DSL | Medium • Streamline Android App Dependencies with buildSrc • Efficient Dependency Management in Android with TOML and Kotlin DSL. | by appstronaut | Medium • Migrate your Android Build from Groovy to Version Catalog. | by Harny Otuoniyo | Mobimeo Technology | Medium • Manage Dependencies/Plugins in a Scalable way with Version Catalog - Easy Guide • Configuration options for the dependabot.yml file - GitHub Docs • Automate dependency updates in Gradle projects with Dependabot | by Volodymyr Buberenko | ProAndroidDev • How to use Dependabot with Gradle’s Version Catalog | Medium • Automating dependency updates in a Compose project | by Jose Alcérreca | Android Developers | Medium
  15. Baparekraf Developer Day 2024 Matur Nuwun Slide is available at

    speakerdeck.com/arifaizin medium.com/@arifaizin instagram.com/arif_faizin Ahmad Arif Faizin Manusia Biasa, Bukan Gajah