-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle.kts
303 lines (266 loc) · 10.6 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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
import com.github.gradle.node.task.NodeTask
import com.github.spotbugs.snom.SpotBugsTask
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.springframework.boot.gradle.plugin.SpringBootPlugin
import org.springframework.boot.gradle.util.VersionExtractor
import java.util.regex.Pattern
plugins {
java
jacoco
idea
pmd
id("com.palantir.git-version") version "3.1.0"
id("com.gorylenko.gradle-git-properties") version "2.4.2"
id("com.diffplug.spotless") version "6.25.0"
id("com.github.ben-manes.versions") version "0.51.0"
id("com.github.spotbugs") version "6.0.26"
id("org.springframework.boot") version "3.3.5"
id("org.liquibase.gradle") version "2.2.2"
id("org.asciidoctor.jvm.convert") version "4.0.3"
id("com.github.node-gradle.node") version "7.1.0"
id("com.adarshr.test-logger") version "4.0.0"
}
val gitVersion: groovy.lang.Closure<String> by extra
version = gitVersion()
group = "demo"
val javaVersion = JavaVersion.VERSION_21
val nodeVersion = "20.9.0"
val spotbugsToolVersion = "4.8.0"
val jacocoToolVersion = "0.8.9"
val pmdToolVersion = "6.54.0"
val primefacesVersion = "14.0.2"
repositories {
mavenCentral()
maven { url = uri("https://repository.primefaces.org") }
}
val asciidoctor: Configuration = configurations.create("asciidoctor")
dependencies {
asciidoctor(enforcedPlatform(SpringBootPlugin.BOM_COORDINATES))
implementation(enforcedPlatform(SpringBootPlugin.BOM_COORDINATES))
annotationProcessor(enforcedPlatform(SpringBootPlugin.BOM_COORDINATES))
testAnnotationProcessor(enforcedPlatform(SpringBootPlugin.BOM_COORDINATES))
liquibaseRuntime(enforcedPlatform(SpringBootPlugin.BOM_COORDINATES))
annotationProcessor("org.projectlombok:lombok")
testAnnotationProcessor("org.projectlombok:lombok")
annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")
annotationProcessor("org.springframework:spring-context-indexer")
asciidoctor("org.springframework.restdocs:spring-restdocs-asciidoctor")
liquibaseRuntime("org.postgresql:postgresql")
liquibaseRuntime("org.liquibase:liquibase-core")
liquibaseRuntime("info.picocli:picocli:4.7.6")
implementation("com.github.spotbugs:spotbugs-annotations")
implementation("org.projectlombok:lombok")
implementation("org.springframework.boot:spring-boot-devtools")
implementation("org.springframework.boot:spring-boot-configuration-processor")
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("org.springframework.boot:spring-boot-starter-aop")
implementation("org.springframework.boot:spring-boot-starter-cache")
implementation("org.springframework.boot:spring-boot-starter-security")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-validation")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.session:spring-session-jdbc")
implementation("org.springframework.boot:spring-boot-starter-thymeleaf")
implementation("org.liquibase:liquibase-core")
implementation("com.github.ben-manes.caffeine:caffeine")
implementation("io.micrometer:micrometer-registry-prometheus")
implementation("org.postgresql:postgresql")
implementation("com.google.code.gson:gson")
implementation("org.joinfaces:primefaces-spring-boot-starter:5.3.5")
implementation("org.primefaces:primefaces:$primefacesVersion:jakarta")
implementation("org.primefaces.extensions:primefaces-extensions:$primefacesVersion:jakarta")
implementation("org.primefaces.themes:bootstrap:1.1.0")
implementation("net.logstash.logback:logstash-logback-encoder:8.0")
implementation("de.ruedigermoeller:fst:3.0.4-jdk17")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.springframework.security:spring-security-test")
testImplementation("org.springframework.restdocs:spring-restdocs-mockmvc")
testImplementation("org.springframework.boot:spring-boot-testcontainers")
testImplementation("org.testcontainers:junit-jupiter")
testImplementation("org.testcontainers:postgresql")
testImplementation("org.testcontainers:selenium")
testImplementation("org.seleniumhq.selenium:selenium-java")
}
java {
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
}
node {
version.set(nodeVersion)
download.set(true)
}
idea {
module {
inheritOutputDirs = false
outputDir = file(layout.buildDirectory.dir("resources/main/"))
}
}
springBoot {
buildInfo()
}
liquibase {
activities {
register("main") {
arguments = mapOf(
"searchPath" to "$projectDir/src/main/resources",
"changeLogFile" to "db/changelog/db.changelog-master.xml",
"url" to "jdbc:postgresql://localhost:5432/spring-demo",
"username" to "dev",
"password" to "dev",
)
}
}
runList = "main"
}
spotbugs {
toolVersion.set(spotbugsToolVersion)
excludeFilter.set(file("spotbugs-exclude.xml"))
}
tasks.withType<SpotBugsTask> {
reports {
create("html").required.set(true)
create("xml").required.set(true)
}
}
pmd {
toolVersion = pmdToolVersion
ruleSetFiles(file("pmd.ruleset.xml"))
ruleSets = listOf()
}
jacoco {
toolVersion = jacocoToolVersion
}
spotless {
java {
eclipse().configFile("spotless.eclipseformat.xml") // XML file dumped out by the Eclipse formatter
indentWithSpaces()
trimTrailingWhitespace()
endWithNewline()
// Eclipse formatter puts excess whitespace after lambda blocks
// funcThatTakesLambdas(x -> {} , y -> {} ) // what Eclipse does
// funcThatTakesLambdas(x -> {}, y -> {}) // what I wish Eclipse did
custom("Lambda fix") {
it.replace("} )", "})").replace("} ,", "},")
}
// Eclipse formatter screws up long literals with underscores inside of annotations (see issue #14)
// @Max(value = 9_999_999 L) // what Eclipse does
// @Max(value = 9_999_999L) // what I wish Eclipse did
custom("Long literal fix") {
Pattern.compile("([0-9_]+) [Ll]").matcher(it).replaceAll("\$1L")
}
}
format("misc") {
target(fileTree(".") {
include(".gitignore", "**/.gitignore", "*.kts", "*.md", "src/**/*.md", "infrastructure/**/*.sh", "src/**/*.sh")
exclude("node_modules/**", "out/**", "build/**")
})
indentWithSpaces()
trimTrailingWhitespace()
endWithNewline()
}
}
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
options.compilerArgs.addAll(listOf("-Xlint:unchecked", "-Xlint:deprecation", "-parameters"))
}
tasks.bootRun {
systemProperty("spring.output.ansi.enabled", "always")
jvmArgs = listOf(
"--add-opens=java.base/java.lang=ALL-UNNAMED",
"--add-opens=java.base/java.math=ALL-UNNAMED",
"--add-opens=java.base/java.util=ALL-UNNAMED",
"--add-opens=java.base/java.util.concurrent=ALL-UNNAMED",
"--add-opens=java.base/java.net=ALL-UNNAMED",
"--add-opens=java.base/java.text=ALL-UNNAMED",
"--add-opens=java.sql/java.sql=ALL-UNNAMED"
)
doFirst {
println(classpath.files.toList())
}
}
tasks.bootJar {
archiveClassifier.set("boot")
layered {
enabled.set(true)
}
}
tasks.jacocoTestReport {
sourceDirectories.setFrom(files("${project.projectDir}/src/main/java"))
classDirectories.setFrom(sourceSets.main.get().output.asFileTree)
executionData.setFrom(fileTree(layout.buildDirectory.dir("jacoco")).include("*.exec"))
dependsOn(tasks.test)
reports {
xml.required.set(true)
html.required.set(true)
}
}
tasks.asciidoctor {
mustRunAfter(tasks.test)
configurations("asciidoctor")
sourceDir("src/docs/asciidoc")
inputs.dir(layout.buildDirectory.dir("generated-snippets"))
setOutputDir(layout.buildDirectory.dir("asciidoc/static/docs"))
jvm {
jvmArgs(
"--add-opens=java.base/sun.nio.ch=ALL-UNNAMED",
"--add-opens=java.base/java.io=ALL-UNNAMED"
)
}
attributes(mapOf(
"springbootversion" to VersionExtractor.forClass(SpringBootPlugin::class.java),
"projectdir" to "$projectDir"
))
doLast {
copy {
from(layout.buildDirectory.dir("asciidoc"))
into(layout.buildDirectory.dir("resources/main"))
}
}
}
tasks.withType<Test> {
outputs.dir(layout.buildDirectory.dir("generated-snippets"))
useJUnitPlatform()
jvmArgs = listOf(
"-XX:+EnableDynamicAgentLoading",
"--add-opens=java.base/java.lang=ALL-UNNAMED",
"--add-opens=java.base/java.math=ALL-UNNAMED",
"--add-opens=java.base/java.util=ALL-UNNAMED",
"--add-opens=java.base/java.util.concurrent=ALL-UNNAMED",
"--add-opens=java.base/java.net=ALL-UNNAMED",
"--add-opens=java.base/java.text=ALL-UNNAMED",
"--add-opens=java.sql/java.sql=ALL-UNNAMED"
)
testLogging {
events = mutableSetOf(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED, /*TestLogEvent.STANDARD_OUT,*/ TestLogEvent.STANDARD_ERROR)
showExceptions = true
exceptionFormat = TestExceptionFormat.FULL
showCauses = true
showStackTraces = true
}
}
val webpack = tasks.register<NodeTask>("webpack") {
dependsOn(tasks.npmInstall)
inputs.files("src/main/resources/static/javascript")
outputs.dir("${layout.buildDirectory.get().asFile}/resources/main/static/javascript")
script.set(project.file("node_modules/webpack/bin/webpack.js"))
environment.put("NODE_OPTIONS", "--openssl-legacy-provider")
}
val webpackWatch = tasks.register<NodeTask>("webpackWatch") {
dependsOn(tasks.npmInstall)
script.set(project.file("node_modules/webpack/bin/webpack.js"))
args.set(listOf("--watch", "--display-error-details"))
}
tasks.wrapper {
gradleVersion = "8.10"
distributionType = Wrapper.DistributionType.ALL
}
tasks {
getByName("spotlessMisc").dependsOn(npmSetup)
processResources.get().dependsOn(webpack, generateGitProperties, getByName("bootBuildInfo"))
compileJava.get().dependsOn(processResources)
spotbugsMain.get().dependsOn(asciidoctor)
jar.get().dependsOn(asciidoctor, test)
bootJar.get().dependsOn(jar, resolveMainClassName)
test.get().finalizedBy(jacocoTestReport)
}