Daniele B
03/08/2021, 2:51 PMbuildSrc
folder.
Is there any reason to use that instead of just define them in the global gradle file buildscript
section?Joost Klitsie
03/08/2021, 3:22 PMdependencies {
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
Javier
03/08/2021, 4:15 PMephemient
03/08/2021, 5:19 PMJoost Klitsie
03/08/2021, 7:00 PMJoost Klitsie
03/08/2021, 7:01 PMJavier
03/08/2021, 7:09 PM