-
Notifications
You must be signed in to change notification settings - Fork 2
/
settings.gradle.kts
32 lines (28 loc) · 1.33 KB
/
settings.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// TODO: Convert to use this plugin once it's published.
/**
* This configures the gradle build so we can use non-standard build file names.
* Additionally, this project can support sub-projects who's build file is written in Kotlin.
*
* @param project The project to configure.
*/
fun configureGradleBuild(project: ProjectDescriptor) {
val projectBuildFileBaseName = project.name
val groovyBuild = File(project.projectDir, "$projectBuildFileBaseName.gradle")
val kotlinBuild = File(project.projectDir, "$projectBuildFileBaseName.gradle.kts")
if (groovyBuild.exists() && kotlinBuild.exists()) {
throw GradleException(
"Project ${project.name} can not have both a ${groovyBuild.name} and a ${kotlinBuild.name} file. " +
"Rename one so that the other can serve as the base for the project's build"
)
}
project.buildFileName = when {
groovyBuild.exists() -> groovyBuild.name
kotlinBuild.exists() -> kotlinBuild.name
else ->
throw GradleException("Project `${project.name}` must have a either a file " +
"containing ${groovyBuild.name} or ${kotlinBuild.name}")
}
// Any nested children projects also get configured.
project.children.forEach { configureGradleBuild(it) }
}
configureGradleBuild(rootProject)