forked from stringconcat/ddd_practice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
148 lines (121 loc) · 4.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
val parentProjectDir = projectDir
plugins {
id(Plugins.kotlin) version PluginVers.kotlin apply false
id(Plugins.detekt) version PluginVers.detekt
id(Plugins.update_dependencies) version PluginVers.update_dependencies
id(Plugins.owasp_dependencies) version PluginVers.owasp_dependencies
id(Plugins.pitest) version PluginVers.pitest apply false
}
subprojects {
configurations.all {
resolutionStrategy {
eachDependency {
requested.version?.contains("snapshot", true)?.let {
if (it) {
throw GradleException("Snapshot found: ${requested.name} ${requested.version}")
}
}
}
}
}
apply {
plugin("java")
plugin(Plugins.kotlin)
plugin(Plugins.detekt)
plugin("jacoco")
plugin(Plugins.update_dependencies)
plugin(Plugins.owasp_dependencies)
plugin(Plugins.pitest)
}
repositories {
jcenter()
mavenCentral()
mavenLocal()
}
detekt {
config = files("$parentProjectDir/detekt/detekt-config.yml")
buildUponDefaultConfig = true
input = files("src/main/kotlin", "src/test/kotlin")
reports {
html.enabled = true
}
dependencies {
detektPlugins("${Plugins.detekt_formatting}:${PluginVers.detekt_formatting}")
}
}
configure<info.solidsoft.gradle.pitest.PitestPluginExtension> {
junit5PluginVersion.set("0.12")
targetClasses.set(listOf("com.stringconcat.*"))
failWhenNoMutations.set(false)
timestampedReports.set(false)
}
tasks {
val check = named<DefaultTask>("check")
val jacocoTestReport = named<JacocoReport>("jacocoTestReport")
val jacocoTestCoverageVerification = named<JacocoCoverageVerification>("jacocoTestCoverageVerification")
val dependencyUpdate =
named<com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask>("dependencyUpdates")
dependencyUpdate {
revision = "release"
outputFormatter = "txt"
checkForGradleUpdate = true
outputDir = "$buildDir/reports/dependencies"
reportfileName = "updates"
}
dependencyUpdate.configure {
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()
}
rejectVersionIf {
isNonStable(candidate.version) && !isNonStable(currentVersion)
}
}
check {
finalizedBy(jacocoTestReport)
finalizedBy(dependencyUpdate)
}
jacocoTestReport {
dependsOn(check)
finalizedBy(jacocoTestCoverageVerification)
}
jacocoTestCoverageVerification {
dependsOn(jacocoTestReport)
violationRules {
rule {
excludes = listOf("application", "telnet")
limit {
minimum = BigDecimal("0.94")
}
}
}
}
val failOnWarning = project.properties["allWarningsAsErrors"] != null && project
.properties["allWarningsAsErrors"] == "true"
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = JavaVersion.VERSION_11.toString()
allWarningsAsErrors = failOnWarning
freeCompilerArgs = listOf("-Xjvm-default=enable")
}
}
withType<JavaCompile> {
options.compilerArgs.add("-Xlint:all")
}
withType<Test> {
useJUnitPlatform()
testLogging {
events(
org.gradle.api.tasks.testing.logging.TestLogEvent.PASSED,
org.gradle.api.tasks.testing.logging.TestLogEvent.FAILED,
org.gradle.api.tasks.testing.logging.TestLogEvent.SKIPPED
)
showStandardStreams = true
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
}
}
}
}