Build files tend to grow in time. New tasks are added, some customizations are made and you end up with several pages of groovy code. Gradle is based on Groovy, so many constructs can be really simplified, but often it’s not enough. That’s where Gradle comes in. You can split your build files into logical pieces:
// in build.gradle apply from: "libraries.gradle" apply from: "subprojectsTasks.gradle"
// in libraries.gradle
versions = [
abc: "1.6"
]
libraries = [
abc: "org.abc:abc:${versions.abc}"
]
// in subprojetsTasks.gradle
subprojects {
apply plugin:"java"
dependencies {
compile libraries.abc
}
}
And that’s it. You can safely split your build file into logical parts.
