-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle.kts
226 lines (199 loc) · 7.47 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
import com.github.jk1.license.render.ReportRenderer
import com.github.jk1.license.render.InventoryHtmlReportRenderer
import com.github.jk1.license.filter.DependencyFilter
import com.github.jk1.license.filter.LicenseBundleNormalizer
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent.FAILED
import org.gradle.api.tasks.testing.logging.TestLogEvent.PASSED
import org.gradle.api.tasks.testing.logging.TestLogEvent.SKIPPED
import org.gradle.api.tasks.testing.logging.TestLogEvent.STARTED
import org.springframework.boot.gradle.plugin.SpringBootPlugin
import org.springframework.boot.gradle.tasks.bundling.BootJar
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath(libs.plugin.kotlin)
}
}
@Suppress("DSL_SCOPE_VIOLATION")
plugins {
kotlin("jvm") version libs.versions.kotlin.get()
kotlin("plugin.spring") version libs.versions.kotlin.get() apply false
id("scipamato-collect-sarif")
alias(libs.plugins.springBoot).apply(false)
alias(libs.plugins.springDependencyManagement)
alias(libs.plugins.lombok)
idea
jacoco
alias(libs.plugins.detekt)
alias(libs.plugins.sonarqube)
alias(libs.plugins.licenseReport)
}
extra["spring.cloudVersion"] = libs.versions.springCloud.get()
dependencyManagement {
imports {
mavenBom(SpringBootPlugin.BOM_COORDINATES)
mavenBom("org.springframework.cloud:spring-cloud-dependencies:${property("spring.cloudVersion")}")
}
}
val testModuleDirs = setOf("common/common-test", "common/common-persistence-jooq-test")
val testModules = testModuleDirs.map { it.substringAfter("/") }
val testPackages = testModuleDirs.map { "$it/**/*" }
val generatedPackages: Set<String> = setOf(
"**/ch/difty/scipamato/core/db/**",
"**/ch/difty/scipamato/core/pubmed/api/**",
"**/ch/difty/scipamato/publ/db/**"
)
testing {
suites {
@Suppress("UnstableApiUsage")
val test by getting(JvmTestSuite::class) {
useJUnitJupiter()
}
}
}
jacoco {
toolVersion = libs.versions.jacoco.get()
}
val jacocoTestReportFile = layout.buildDirectory.get().asFile.resolve("reports/jacoco/test/jacocoTestReport.xml")
val jacocoTestPattern = "**/build/jacoco/*.exec"
val genPkg = generatedPackages.joinToString(",")
val detektReportFile = layout.buildDirectory.get().asFile.resolve("reports/detekt/detekt.xml")
sonarqube {
properties {
property("sonar.host.url", "https://sonarcloud.io")
property("sonar.projectKey", "ursjoss_${project.name}")
property("sonar.organization", "ursjoss-github")
property("sonar.exclusions", "**/ch/difty/scipamato/publ/web/themes/markup/html/publ/**/*,$genPkg")
property("sonar.coverage.exclusions", (generatedPackages + testPackages).joinToString(","))
property("sonar.coverage.jacoco.xmlReportPaths", jacocoTestReportFile)
property("sonar.kotlin.detekt.reportPaths", detektReportFile)
}
}
kotlin {
jvmToolchain {
languageVersion.set(JavaLanguageVersion.of(libs.versions.java.get()))
}
}
subprojects {
apply<SpringBootPlugin>()
apply(plugin = "io.spring.dependency-management")
apply(plugin = "org.jetbrains.kotlin.jvm")
apply<ScipamatoDetektPlugin>()
apply<CollectSarifPlugin>()
apply<ScipamatoJacocoPlugin>()
apply<JavaPlugin>()
apply<IdeaPlugin>()
apply<JacocoPlugin>()
testing {
suites {
@Suppress("UnstableApiUsage", "unused")
val test by getting(JvmTestSuite::class) {
useJUnitJupiter()
}
}
}
// Breaks running the project from the IntelliJ Run Dashboard - disabling for now
// idea {
// module {
// // https://structure101.com/2018/12/01/structure101-workspace-intellij-idea-and-gradle/
// outputDir = file("$buildDir/classes/java/main")
// testOutputDir = file("$buildDir/classes/java/test")
// inheritOutputDirs = false
// }
// }
if (!isWebProject()) {
apply(plugin = "java-library")
}
dependencies {
implementation(rootProject.libs.kotlin.reflect)
compileOnly(rootProject.libs.lombok)
annotationProcessor(rootProject.libs.lombok)
api(rootProject.libs.slf4j.api)
implementation(rootProject.libs.kotlinLogging)
runtimeOnly(rootProject.libs.logback.core)
compileOnly(rootProject.libs.jsr305)
testImplementation(rootProject.libs.spring.boot.starter.test) {
exclude("junit", "junit")
exclude("org.skyscreamer", "jsonassert")
exclude("org.mockito", "mockito-core")
exclude("org.mockito", "mockito-junit-jupiter")
exclude("org.hamcrest", "hamcrest")
exclude("org.assertj", "assertj-core")
}
testImplementation(rootProject.libs.kotest.framework.api)
testImplementation(rootProject.libs.kotest.property)
testImplementation(rootProject.libs.kluent) {
exclude("org.mockito", "mockito-core")
exclude("com.nhaarman.mockitokotlin2", "mockito-kotlin")
}
testImplementation(rootProject.libs.mockk)
testImplementation(rootProject.libs.springMockk)
testRuntimeOnly(rootProject.libs.kotest.runner.junit5)
}
tasks {
named("compileKotlin", org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask::class.java) {
compilerOptions {
freeCompilerArgs.add("-opt-in=kotlin.RequiresOptIn")
}
}
val deleteOutFolderTask by registering(Delete::class) {
delete("out")
}
named("clean") {
dependsOn(deleteOutFolderTask)
}
withType<Test> {
maxHeapSize = "2g"
failFast = true
testLogging {
events = setOf(STARTED, FAILED, PASSED, SKIPPED)
showStackTraces = true
exceptionFormat = TestExceptionFormat.FULL
}
}
withType<Jar> {
enabled = !isWebProject()
}
withType<BootJar> {
enabled = false
}
register("version") {
doLast {
println(project.version)
}
}
register("printSourceSetInformation") {
doLast {
sourceSets.forEach { srcSet ->
println("[" + srcSet.name + "]")
println("-->Source directories: " + srcSet.allJava.srcDirs)
println("-->Output directories: " + srcSet.output.classesDirs.files)
println("-->Compile classpath:")
// srcSet.compileClasspath.files.forEach { println(" " + it.path) }
println("")
}
}
}
}
// see https://github.com/detekt/detekt/issues/6198
configurations.matching { it.name == "detekt" }.all {
resolutionStrategy.eachDependency {
if (requested.group == "org.jetbrains.kotlin") {
useVersion(libs.versions.detektKotlinVersion.get())
}
}
}
}
tasks.named("compileKotlin", org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask::class.java) {
compilerOptions {
freeCompilerArgs.add("-Xjsr305=strict")
}
}
licenseReport {
renderers = arrayOf<ReportRenderer>(InventoryHtmlReportRenderer("report.html", "Backend"))
filters = arrayOf<DependencyFilter>(LicenseBundleNormalizer())
}
fun Project.isWebProject() = path.endsWith("web")