forked from Kotlin-Android-Open-Source/MVI-Coroutines-Flow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
121 lines (103 loc) · 3.09 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
import java.util.EnumSet
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id("org.jetbrains.kotlinx.kover") version "0.8.3" apply false
id("com.diffplug.spotless") version "6.25.0" apply false
}
buildscript {
repositories {
google()
mavenCentral()
gradlePluginPortal()
maven(url = "https://oss.sonatype.org/content/repositories/snapshots")
}
dependencies {
classpath("com.android.tools.build:gradle:8.6.0")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
classpath("com.diffplug.spotless:spotless-plugin-gradle:6.25.0")
classpath("dev.drewhamilton.poko:poko-gradle-plugin:0.17.0")
classpath("com.github.ben-manes:gradle-versions-plugin:0.51.0")
}
}
subprojects {
apply(plugin = "com.github.ben-manes.versions")
fun isNonStable(version: String): Boolean {
val stableKeyword =
listOf("RELEASE", "FINAL", "GA")
.any { version.uppercase().contains(it) }
val regex = "^[0-9,.v-]+(-r)?$".toRegex()
val isStable = stableKeyword || regex.matches(version)
return !isStable
}
fun isStable(version: String) = !isNonStable(version)
tasks.withType<DependencyUpdatesTask> {
rejectVersionIf {
if (isStable(currentVersion)) {
isNonStable(candidate.version)
} else {
false
}
}
}
afterEvaluate {
tasks.withType<Test> {
maxParallelForks =
(Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1).also {
println("Setting maxParallelForks to $it")
}
testLogging {
showExceptions = true
showCauses = true
showStackTraces = true
showStandardStreams = true
events =
EnumSet.of(
TestLogEvent.PASSED,
TestLogEvent.FAILED,
TestLogEvent.SKIPPED,
TestLogEvent.STANDARD_OUT,
TestLogEvent.STANDARD_ERROR,
)
exceptionFormat = TestExceptionFormat.FULL
}
}
}
}
allprojects {
extensions.findByType<kotlinx.kover.gradle.plugin.dsl.KoverProjectExtension>()?.run {
useJacoco("0.8.11")
}
tasks.withType<KotlinCompile> {
kotlinOptions {
val version = JavaVersion.VERSION_11.toString()
jvmTarget = version
}
}
apply<com.diffplug.gradle.spotless.SpotlessPlugin>()
configure<com.diffplug.gradle.spotless.SpotlessExtension> {
kotlin {
target("**/*.kt")
ktlint(ktlintVersion)
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
}
format("xml") {
target("**/res/**/*.xml")
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
}
kotlinGradle {
target("**/*.gradle.kts", "*.gradle.kts")
ktlint(ktlintVersion)
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
}
}
}