Skip to content

Commit 8adb37c

Browse files
authored
Update CommunityProjectsBuild.kt (Kotlin#4229)
1 parent eac92c0 commit 8adb37c

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

buildSrc/src/main/kotlin/CommunityProjectsBuild.kt

+8-12
Original file line numberDiff line numberDiff line change
@@ -134,20 +134,16 @@ fun getOverriddenKotlinVersion(project: Project): String? =
134134
/**
135135
* Checks if the project is built with a snapshot version of Kotlin compiler.
136136
*/
137-
fun isSnapshotTrainEnabled(project: Project): Boolean =
138-
when (project.rootProject.properties["build_snapshot_train"]) {
139-
null -> false
140-
"" -> false
141-
else -> true
142-
}
137+
fun isSnapshotTrainEnabled(project: Project): Boolean {
138+
val buildSnapshotTrain = project.rootProject.properties["build_snapshot_train"] as? String
139+
return !buildSnapshotTrain.isNullOrBlank()
140+
}
143141

144142
fun shouldUseLocalMaven(project: Project): Boolean {
145-
var someDependencyIsSnapshot = false
146-
project.rootProject.properties.forEach { key, value ->
147-
if (key.endsWith("_version") && value is String && value.endsWith("-SNAPSHOT")) {
148-
println("NOTE: USING SNAPSHOT VERSION: $key=$value")
149-
someDependencyIsSnapshot = true
143+
val hasSnapshotDependency = project.rootProject.properties.any { (key, value) ->
144+
key.endsWith("_version") && value is String && value.endsWith("-SNAPSHOT").also {
145+
if (it) println("NOTE: USING SNAPSHOT VERSION: $key=$value")
150146
}
151147
}
152-
return isSnapshotTrainEnabled(project) || someDependencyIsSnapshot
148+
return hasSnapshotDependency || isSnapshotTrainEnabled(project)
153149
}

0 commit comments

Comments
 (0)