Member-only story
Better Dependency Management Using buildSrc + Kotlin DSL
Dependency management for better reusability and easy maintenance
Introduction
Since the start of using Android Studio, Gradle has become a central place for managing many things like dependencies, config data, flavours, etc. And maintaining the dependencies across multi-module projects has become a challenge over time. Let’s see in detail how the evolution of dependencies management across multi-module projects happened and the problems faced. Please check out my previous post on Kotlin DSL for a better understanding
The core part of this post is how we can achieve better dependencies management using buildSrc and Kotlin DSL
Problem
If you want to skip the evolution process move to the usage of buidSrc with Kotlin DSL section else continue reading.
Let’s take a multi-module app to understand the problem. Manually declaring versions along with dependencies across multi modules is our first approach. That would look something like below
At first module build.gradle file we declare dependencies
implementation "androidx.appcompat:appcompat:1.0.0"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.41"
xxxxxx
