-
Notifications
You must be signed in to change notification settings - Fork 34
/
build.gradle.kts
48 lines (38 loc) · 1.47 KB
/
build.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import com.diffplug.gradle.spotless.SpotlessExtensionPredeclare
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
import java.io.FileInputStream
import java.util.Properties
plugins {
id("spotless-conventions")
alias(libs.plugins.task.tree)
alias(libs.plugins.gradle.versions)
alias(libs.plugins.gradle.dependency.analysis)
}
val localProps = Properties()
localProps.load(FileInputStream(File(rootDir, "local.properties")))
val ndkDir: String =
File(localProps["sdk.dir"].toString(), "ndk/" + libs.versions.sdk.ndk.get()).absolutePath
allprojects {
project.extra.set("ndkDir", ndkDir)
project.extra.set("nativeDir", rootDir.absolutePath + "/native")
project.extra.set("daemonDex", "daemon.dx")
project.extra.set("noPro", !File(rootDir, "configs/pro-app.gradle").isFile)
}
// https://github.com/diffplug/spotless/issues/1380#issuecomment-1405392506
spotless { predeclareDeps() }
configure<SpotlessExtensionPredeclare> {
java { googleJavaFormat() }
kotlin { ktfmt() }
}
fun isStableVersion(version: String): Boolean {
return ".*-(rc|beta|alpha)(|-)[0-9]*$".toRegex().matches(version.lowercase()).not()
}
tasks.register<GradleBuild>("buildSrcDependencyUpdates") {
dir = File(rootDir, "buildSrc")
tasks = mutableListOf("dependencyUpdates")
buildName = "buildSource"
}
tasks.withType<DependencyUpdatesTask> {
dependsOn("buildSrcDependencyUpdates")
rejectVersionIf { !isStableVersion(candidate.version) && isStableVersion(currentVersion) }
}