-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle.kts
190 lines (170 loc) · 7.57 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
import info.solidsoft.gradle.pitest.PitestPluginExtension
import info.solidsoft.gradle.pitest.PitestTask
plugins {
id("com.diffplug.spotless") version "7.0.0.BETA4"
id("info.solidsoft.pitest") version "1.15.0" apply false
id("com.github.ben-manes.versions") version "0.51.0"
id("net.ltgt.errorprone") version "4.1.0" apply false
}
val errorProneVersion = "2.36.0"
val ktlintVersion = "1.5.0"
val pitestMainVersion = "1.17.3"
val pitestJUnit5PluginVersion = "1.2.1"
ext["jmhVersion"] = "1.37"
configurations {
register("dependencyUpdates")
}
dependencies {
"dependencyUpdates"("org.pitest:pitest-junit5-plugin:$pitestJUnit5PluginVersion")
"dependencyUpdates"("org.pitest:pitest:$pitestMainVersion")
"dependencyUpdates"("com.pinterest.ktlint:ktlint-bom:$ktlintVersion")
}
spotless {
kotlinGradle {
target("**/*.gradle.kts")
ktlint(ktlintVersion).editorConfigOverride(mapOf("ktlint_standard_trailing-comma-on-call-site" to "disabled"))
}
}
allprojects {
beforeEvaluate {
apply(plugin = "com.diffplug.spotless")
tasks.withType(Test::class.java).configureEach {
useJUnitPlatform()
}
group = "io.github.davidburstrom.contester"
version = "0.2.0"
plugins.whenPluginAdded {
if (this is JavaPlugin) {
configure<JavaPluginExtension> {
toolchain {
// Could theoretically be version 8, but it's not compatible with
// ErrorProne. Therefore, the JavaCompile release option is used.
languageVersion = JavaLanguageVersion.of(17)
}
}
/*
* Automatically format all Java sources prior to usage.
*/
project.tasks.withType<SourceTask>().configureEach {
if (this.name != "spotlessJavaApply") {
dependsOn("spotlessJavaApply")
}
}
project.tasks.withType<JavaCompile> {
options.release = 8
options.compilerArgs.add("-Werror")
}
spotless {
java {
googleJavaFormat()
licenseHeaderFile(rootProject.file("config/license-header.txt"))
}
}
apply(plugin = "pmd")
configure<PmdExtension> {
ruleSets = listOf()
ruleSetConfig = resources.text.fromFile(rootProject.file("config/pmd/rulesets.xml"))
}
}
if (this is MavenPublishPlugin && project.properties["ossrh.username"] != null) {
configure<PublishingExtension> {
repositories {
maven {
name = "MavenCentral"
url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = project.properties["ossrh.username"] as String
password = project.properties["ossrh.password"] as String
}
}
}
}
afterEvaluate {
configure<PublishingExtension> {
publications.named<MavenPublication>("maven") {
pom {
url = "https://github.com/davidburstrom/contester"
licenses {
license {
name = "The Apache License, Version 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
developers {
developer {
id = "davidburstrom"
name = "David Burström"
email = "[email protected]"
}
}
scm {
connection = "scm:git:git://github.com/davidburstrom/contester.git"
developerConnection = "scm:git:ssh://github.com/davidburstrom/contester.git"
url = "https://github.com/davidburstrom/contester"
}
}
}
}
tasks.named("publishMavenPublicationToMavenCentralRepository") {
doFirst {
if (gradle.startParameter.isParallelProjectExecutionEnabled) {
throw AssertionError("Must execute serially, otherwise Nexus can create multiple staging repos")
}
}
}
}
}
}
afterEvaluate {
if (plugins.hasPlugin(JavaPlugin::class.java)) {
apply(plugin = "info.solidsoft.pitest")
configure<PitestPluginExtension> {
pitestVersion = pitestMainVersion
junit5PluginVersion = pitestJUnit5PluginVersion
timestampedReports = false
targetClasses = setOf("io.github.davidburstrom.contester.*")
threads = 4
failWhenNoMutations = false
mutators = listOf("DEFAULTS")
timeoutConstInMillis = 200
/* Run Pitest always, if it has a threshold set. */
if (ext.has("mutationThreshold")) {
mutationThreshold = ext.get("mutationThreshold") as Int
tasks.named("build").configure {
dependsOn("pitest")
}
}
}
tasks.named<PitestTask>("pitest").configure {
inputs.property("src", file("src/test"))
onlyIf {
(inputs.properties["src"] as File).exists()
}
javaLauncher = project.extensions.getByType<JavaToolchainService>().launcherFor {
languageVersion = JavaLanguageVersion.of(8)
}
/*
* Carry over all system properties defined for test tasks into the Pitest tasks, except for the "junit"
* ones, as they can interfere with test stability.
*/
systemProperties(
tasks.getByName<Test>("test").systemProperties.filterKeys {
!it.contains(
"junit"
)
}
)
/*
* Include a "pitest" system property to be able to run tests differently if necessary. Use sparingly!
*/
systemProperty("pitest", "true")
outputs.cacheIf { true }
}
apply(plugin = "net.ltgt.errorprone")
dependencies {
"errorprone"("com.google.errorprone:error_prone_core:$errorProneVersion")
}
}
}
}
}