-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathbuild.gradle.kts
127 lines (115 loc) · 3.64 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
import com.diffplug.gradle.spotless.SpotlessExtension
import com.github.spotbugs.snom.Confidence
import com.github.spotbugs.snom.Effort
import com.github.spotbugs.snom.SpotBugsExtension
import com.github.spotbugs.snom.SpotBugsTask
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
logger.quiet("Java version: ${JavaVersion.current()}")
logger.quiet("Gradle version: ${gradle.gradleVersion}")
plugins {
id("java-library")
alias(libs.plugins.spotless)
alias(libs.plugins.spotbugs)
alias(libs.plugins.buildtimetracker)
}
allprojects {
group = "com.willmolloy"
repositories {
mavenCentral()
}
apply(plugin = "java")
configure<JavaPluginExtension> {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
apply(plugin = "com.diffplug.spotless")
configure<SpotlessExtension> {
// https://github.com/diffplug/spotless/tree/main/plugin-gradle#java
java {
removeUnusedImports()
googleJavaFormat()
trimTrailingWhitespace()
endWithNewline()
}
// https://github.com/diffplug/spotless/tree/main/plugin-gradle#kotlin
kotlin {
ktfmt().googleStyle()
trimTrailingWhitespace()
endWithNewline()
}
kotlinGradle {
ktlint().editorConfigOverride(mapOf("ktlint_standard_no-empty-file" to "disabled"))
trimTrailingWhitespace()
endWithNewline()
}
// https://github.com/diffplug/spotless/tree/main/plugin-gradle#scala
scala {
scalafmt().configFile("$rootDir/scalafmt.conf")
trimTrailingWhitespace()
endWithNewline()
}
}
// TODO Kotlin/Scala alternative?
apply(plugin = "checkstyle")
configure<CheckstyleExtension> {
toolVersion = "10.12.0"
configFile = rootProject.file("./checkstyle.xml")
configProperties = mapOf("suppressionFile" to rootProject.file("./checkstyle-suppressions.xml"))
maxErrors = 0
maxWarnings = 0
isIgnoreFailures = false
}
apply(plugin = "com.github.spotbugs")
configure<SpotBugsExtension> {
effort.set(Effort.MAX)
reportLevel.set(Confidence.LOW)
ignoreFailures.set(false)
excludeFilter.set(rootProject.file("./spotbugs-exclude.xml"))
}
tasks.withType<SpotBugsTask> {
reports.create("html").required.set(true)
}
tasks.withType<Test> {
maxParallelForks = Runtime.getRuntime().availableProcessors()
useJUnitPlatform()
testLogging {
events = setOf(TestLogEvent.FAILED, TestLogEvent.SKIPPED)
exceptionFormat = TestExceptionFormat.FULL
showExceptions = true
showCauses = true
showStackTraces = true
afterSuite(
KotlinClosure2({ desc: TestDescriptor, result: TestResult ->
if (desc.parent == null) {
println(
"Results: ${result.resultType} " +
"(${result.testCount} test${if (result.testCount > 1) "s" else ""}, " +
"${result.successfulTestCount} passed, " +
"${result.failedTestCount} failed, " +
"${result.skippedTestCount} skipped)",
)
}
}),
)
}
finalizedBy(tasks.withType<JacocoReport>())
}
apply(plugin = "jacoco")
tasks.withType<JacocoReport> {
reports {
xml.required.set(true)
}
}
dependencies {
implementation(rootProject.libs.spotbugs.annotations)
testImplementation(rootProject.libs.junit)
testImplementation(rootProject.libs.truth)
testImplementation(rootProject.libs.mockito.core)
testImplementation(rootProject.libs.mockito.junit)
configurations.all {
exclude(group = "org.assertj")
exclude(group = "junit")
}
}
}