-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.gradle.kts
97 lines (77 loc) · 2.6 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
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
buildscript {
apply(from = ".buildscripts/git-hooks.gradle")
}
plugins {
kotlin("jvm") version ("1.9.0") apply false
id("com.github.ben-manes.versions") version ("0.42.0") apply false
id("io.gitlab.arturbosch.detekt") version ("1.21.0") apply false
id("com.github.node-gradle.node") version ("5.0.0") apply false
id("org.jetbrains.kotlinx.kover") version ("0.7.2") apply false
}
allprojects {
group = "com.legacycode"
repositories {
mavenCentral()
}
}
subprojects {
if (this.name == "web-client-react") {
return@subprojects
}
apply(plugin = "com.github.ben-manes.versions")
apply(plugin = "org.jetbrains.kotlin.jvm")
apply(plugin = "org.jetbrains.kotlinx.kover")
if (!isBytecodeSample()) {
apply(plugin = "io.gitlab.arturbosch.detekt")
}
dependencies {
val implementation by configurations
val testImplementation by configurations
val testRuntimeOnly by configurations
// logging
implementation(rootProject.libs.logback)
// testing
testImplementation(kotlin("test-junit5"))
testImplementation(rootProject.testLibs.junit.api)
testImplementation(rootProject.testLibs.junit.params)
testRuntimeOnly(rootProject.testLibs.junit.engine)
testImplementation(rootProject.testLibs.truth)
testImplementation(rootProject.testLibs.approvalTests)
testImplementation(rootProject.testLibs.gson) /* Used by Approvals for pretty-printing JSON */
}
val projectUsesJava16Toolchain = this.name == "bytecode-scanner-tests"
|| this.name == "bytecode-samples-java"
if (!projectUsesJava16Toolchain) {
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "11"
}
tasks.withType<JavaCompile> {
sourceCompatibility = JavaVersion.VERSION_11.toString()
targetCompatibility = JavaVersion.VERSION_11.toString()
}
}
tasks.withType<Test> {
useJUnitPlatform()
}
tasks.withType<JacocoReport> {
dependsOn(tasks.withType(Test::class.java))
reports {
csv.required.set(false)
xml.required.set(true)
}
}
}
fun isNonStable(version: String): Boolean {
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.toUpperCase().contains(it) }
val regex = "^[0-9,.v-]+(-r)?$".toRegex()
val isStable = stableKeyword || regex.matches(version)
return isStable.not()
}
tasks.withType<DependencyUpdatesTask> {
rejectVersionIf { isNonStable(candidate.version) }
}
fun Project.isBytecodeSample(): Boolean {
return this.name.startsWith("bytecode-samples-", true)
}