-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle.kts
117 lines (104 loc) · 3.42 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
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
import io.gitlab.arturbosch.detekt.Detekt
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
jacoco
val kotlinVersion = "1.6.0"
kotlin("jvm") version kotlinVersion apply false
kotlin("kapt") version kotlinVersion apply false
kotlin("plugin.spring") version kotlinVersion apply false
kotlin("plugin.allopen") version kotlinVersion apply false
id("io.gitlab.arturbosch.detekt") version "1.19.0"
id("org.jlleitschuh.gradle.ktlint") version "10.1.0"
id("com.github.ben-manes.versions") version "0.39.0"
}
allprojects {
group = "org.kotlink"
version = "0.0.1-SNAPSHOT"
repositories {
mavenLocal()
mavenCentral()
}
}
subprojects {
apply<JavaPlugin>()
apply<JacocoPlugin>()
configure<JavaPluginExtension> {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
tasks {
withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "11"
freeCompilerArgs = listOf("-Xjsr305=strict")
}
}
withType<Test> {
testLogging.apply {
events("passed", "skipped", "failed")
exceptionFormat = TestExceptionFormat.FULL
debug {
showStandardStreams = true
}
}
}
}
}
dependencies {
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.19.0")
}
ktlint {
enableExperimentalRules.set(false)
disabledRules.set(setOf("final-newline"))
filter {
disabledRules.set(setOf("final-newline", "indent"))
}
filter {
exclude("**.kts")
}
}
tasks {
val detekt by named("detekt", Detekt::class) {
description = "Runs Detekt to perform code analysis"
buildUponDefaultConfig = true
config.setFrom(files(projectDir.resolve("detekt.yml")))
setSource(files(*subprojects.map { "${it.projectDir}/src" }.toTypedArray()))
autoCorrect = false
ignoreFailures = false
reports {
sarif.required.set(true)
}
}
val check by registering {
dependsOn(detekt)
}
register("build") {
dependsOn(check)
}
register("jacocoAggregatedReport", JacocoReport::class) {
reports.html.required.set(true)
reports.xml.required.set(true)
subprojects.filter { it.name != "assembly" }.forEach { subProject ->
dependsOn(subProject.tasks.findByPath("test"))
executionData(subProject.tasks.findByPath("test"))
additionalSourceDirs(files("${subProject.projectDir}/src/kotlin/main"))
additionalClassDirs(files("${subProject.buildDir}/classes/kotlin/main"))
}
}
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()
}
named<DependencyUpdatesTask>("dependencyUpdates") {
checkConstraints = true
revision = "release"
gradleReleaseChannel = "current"
rejectVersionIf {
isNonStable(candidate.version) && !isNonStable(currentVersion)
}
}
}