-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
230 lines (197 loc) · 6.63 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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
import com.adarshr.gradle.testlogger.theme.ThemeType
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
`java-library`
id("com.diffplug.gradle.spotless") version Versions.spotlessPlugin
id("com.adarshr.test-logger") version Versions.testLoggerPlugin
jacoco
kotlin("jvm") version Versions.kotlin
id("org.jlleitschuh.gradle.ktlint") version Versions.ktlintPlugin
id("io.gitlab.arturbosch.detekt") version Versions.detektPlugin
}
val kotlinProjects = listOf(
project(":agent"),
project(":testUtil"),
project(":di"),
project(":ui"),
project(":util")
)
allprojects {
apply {
plugin("com.diffplug.gradle.spotless")
plugin("com.adarshr.test-logger")
}
group = "com.octogonapus"
version = Versions.omj
repositories {
mavenCentral()
jcenter {
content {
includeGroup("org.jetbrains.kotlinx")
includeGroup("org.koin")
}
}
}
// Configures the Jacoco tool version to be the same for all projects that have it applied.
pluginManager.withPlugin("jacoco") {
// If this project has the plugin applied, configure the tool version.
jacoco {
toolVersion = Versions.jacocoTool
}
}
tasks.withType<Test> {
testLogging {
showStandardStreams = true
exceptionFormat = TestExceptionFormat.FULL
}
}
testlogger {
theme = ThemeType.STANDARD_PARALLEL
showStandardStreams = true
}
spotless {
kotlinGradle {
ktlint(Versions.ktlint)
trimTrailingWhitespace()
}
freshmark {
trimTrailingWhitespace()
indentWithSpaces(2)
endWithNewline()
}
format("extraneous") {
target("src/**/*.fxml")
trimTrailingWhitespace()
indentWithSpaces(2)
endWithNewline()
}
}
}
subprojects {
apply {
plugin("java-library")
plugin("jacoco")
}
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
options.isIncremental = true
}
tasks.test {
useJUnitPlatform {
filter {
includeTestsMatching("*Test")
includeTestsMatching("*Tests")
includeTestsMatching("*Spec")
}
/*
These tests just test performance and should not run in CI.
*/
excludeTags("performance")
/*
These tests are too slow to run in CI.
*/
excludeTags("slow")
testLogging {
events(
TestLogEvent.FAILED,
TestLogEvent.PASSED,
TestLogEvent.SKIPPED,
TestLogEvent.STARTED
)
displayGranularity = 0
showExceptions = true
showCauses = true
showStackTraces = true
exceptionFormat = TestExceptionFormat.FULL
showStandardStreams = true
}
reports.junitXml.destination = file(rootProject.buildDir.toPath().resolve("test-results").resolve(project.name))
}
}
tasks.withType<JacocoReport> {
reports {
html.isEnabled = true
xml.isEnabled = true
csv.isEnabled = false
}
}
spotless {
java {
googleJavaFormat("1.8")
removeUnusedImports()
trimTrailingWhitespace()
endWithNewline()
licenseHeaderFile(rootProject.rootDir.toPath().resolve("config").resolve("spotless").resolve("omj.license"))
}
}
}
configure(kotlinProjects) {
apply {
plugin("kotlin")
plugin("org.jlleitschuh.gradle.ktlint")
plugin("io.gitlab.arturbosch.detekt")
}
dependencies {
implementation(group = "org.jetbrains.kotlin", name = "kotlin-stdlib-jdk8", version = Versions.kotlin)
implementation(group = "org.jetbrains.kotlin", name = "kotlin-reflect", version = Versions.kotlin)
implementation(group = "io.github.microutils", name = "kotlin-logging", version = Versions.kotlinLogging)
implementation(group = "org.koin", name = "koin-core", version = Versions.koin)
}
tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs = listOf("-Xopt-in=kotlin.RequiresOptIn")
}
}
spotless {
kotlin {
ktlint(Versions.ktlint)
licenseHeaderFile(rootProject.rootDir.toPath().resolve("config").resolve("spotless").resolve("omj.license"))
}
}
// Always run ktlintFormat after spotlessApply
tasks.named("spotlessApply").configure {
finalizedBy(tasks.named("ktlintFormat"))
}
ktlint {
version.set(Versions.ktlint)
enableExperimentalRules.set(true)
additionalEditorconfigFile.set(file(rootProject.rootDir.toPath().resolve("config").resolve("ktlint").resolve(".editorconfig")))
}
detekt {
input = files("src/main/kotlin", "src/test/kotlin")
parallel = true
config = files(rootProject.rootDir.toPath().resolve("config").resolve("detekt").resolve("config.yml"))
}
}
val jacocoRootReport by tasks.creating(JacocoReport::class) {
group = "verification"
// The agent-tests projects are glorified strings; no point in getting coverage for them.
val excludedProjects = listOf(project(":agent-tests")) + project(":agent-tests").subprojects
val includedProjects = subprojects.filter { it !in excludedProjects }
dependsOn(includedProjects.flatMap { it.tasks.withType(JacocoReport::class) } - this)
val allSrcDirs = includedProjects.map { it.sourceSets.main.get().allSource.srcDirs }
additionalSourceDirs.setFrom(allSrcDirs)
sourceDirectories.setFrom(allSrcDirs)
classDirectories.setFrom(includedProjects.map { it.sourceSets.main.get().output })
executionData.setFrom(
includedProjects.filter {
File("${it.buildDir}/jacoco/test.exec").exists()
}.flatMap { it.tasks.withType(JacocoReport::class).map { it.executionData } }
)
reports {
html.isEnabled = true
xml.isEnabled = true
csv.isEnabled = false
}
}
tasks.wrapper {
distributionType = Wrapper.DistributionType.ALL
gradleVersion = Versions.gradleWrapper
}