I think this is more of a gradle question, but if you use buildSrc you can actually write normal code, create functions etc. which you can call from your build.gradle. Also I can never find the ext.whatever declarations from my projects build.gradle by simply `ctrl`+`clicking` on it, something you can do with code from buildSrc.
If you have a multi module project, you can simply write:
dependencies {
implementBaseDependencies()
}
and then
implementBaseDependencies()
would be a function in your buildSrc that implements all your base dependencies. (I mean this is just a stupid example but you get the gist). A copy paste from my project:
object Serialization {
private const val Version = "1.1.0"
private fun serialization(dependency: String) = group(GroupKotlinX, dependency, Version)
private const val Core = "kotlinx-serialization-core"
private const val Json = "kotlinx-serialization-json"
fun DependencyHandlerScope.implementSerialization(flavor: String = "") {
implementation(serialization(Core), flavor)
implementation(serialization(Json), flavor)
}
}
In this case I can simply call
implementSerialization()
from my
build.gradle
and I have it, it wouldn't look as nice using
buildScript