-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.gradle
More file actions
212 lines (180 loc) · 8.48 KB
/
Copy pathbuild.gradle
File metadata and controls
212 lines (180 loc) · 8.48 KB
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
import groovy.xml.XmlSlurper
plugins {
id 'checkstyle'
id 'java'
id 'jacoco'
id 'com.diffplug.spotless' version '8.2.1'
id 'com.github.ben-manes.versions' version '0.53.0'
id 'com.gorylenko.gradle-git-properties' version '2.5.2'
id 'org.springframework.boot' version '4.0.2'
id 'io.spring.dependency-management' version '1.1.7'
id "com.github.node-gradle.node" version "7.1.0"
}
group = 'de.tum.cit.aet'
version = '0.1.0'
description = 'PositionManager'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(25)
}
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
wrapper {
gradleVersion = "9.3.1"
}
repositories {
mavenCentral()
maven { url 'https://repo.spring.io/milestone' }
}
spotless {
java {
target "src/*/java/**/*.java"
removeUnusedImports()
trimTrailingWhitespace()
endWithNewline()
}
}
checkstyle {
// Exclude everything under the build directory
toolVersion = "${checkstyleVersion}"
configFile = file("checkstyle.xml")
checkstyleTest.enabled = false
maxErrors = 0
}
node {
download = true
version = "24.12.0"
npmVersion = "11.6.2"
workDir = file("${project.projectDir}/.gradle/nodejs")
nodeProjectDir = file("${project.projectDir}/src/main/webapp")
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-liquibase'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-resource-server'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-webmvc'
implementation 'org.springframework.boot:spring-boot-starter-json'
// use newest version of nimbus-jose-jwt to avoid security issues through outdated dependencies
implementation "com.nimbusds:nimbus-jose-jwt:10.7"
// Main database to persist entities
implementation 'org.postgresql:postgresql:42.7.9'
// Keycloak admin client for user lookup via LDAP
implementation 'org.keycloak:keycloak-admin-client:26.0.0'
// Lombok for boilerplate code reduction
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
testImplementation 'org.springframework.boot:spring-boot-starter-actuator-test'
testImplementation 'org.springframework.boot:spring-boot-starter-data-jpa-test'
testImplementation 'org.springframework.boot:spring-boot-starter-liquibase-test'
testImplementation 'org.springframework.boot:spring-boot-starter-validation-test'
testImplementation 'org.springframework.boot:spring-boot-starter-webmvc-test'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
testImplementation 'org.springframework.boot:spring-boot-testcontainers'
testImplementation platform('org.testcontainers:testcontainers-bom:2.0.3')
testImplementation 'org.testcontainers:testcontainers-postgresql'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
springBoot {
buildInfo()
}
gitProperties {
failOnNoGitDirectory = false
keys = ['git.branch', 'git.commit.id.abbrev', 'git.commit.time']
}
tasks.named('test') {
useJUnitPlatform()
finalizedBy jacocoTestReport
testLogging {
events "passed", "skipped", "failed"
showStandardStreams = false
exceptionFormat = "full"
showCauses = true
showStackTraces = true
}
afterSuite { desc, result ->
if (!desc.parent) {
println ""
println "═══════════════════════════════════════════════════════════════"
println " Test Results: ${result.resultType}"
println "═══════════════════════════════════════════════════════════════"
println " Total: ${result.testCount}"
println " Passed: ${result.successfulTestCount}"
println " Failed: ${result.failedTestCount}"
println " Skipped: ${result.skippedTestCount}"
println "═══════════════════════════════════════════════════════════════"
}
}
}
jacocoTestReport {
dependsOn test
reports {
xml.required = true
html.required = true
}
doLast {
def report = file("${layout.buildDirectory.get()}/reports/jacoco/test/jacocoTestReport.xml")
if (report.exists()) {
def parser = new XmlSlurper()
parser.setFeature("http://apache.org/xml/features/disallow-doctype-decl", false)
parser.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false)
def xml = parser.parse(report)
def counters = xml.counter
def instructionCounter = counters.find { it.@type == 'INSTRUCTION' }
def branchCounter = counters.find { it.@type == 'BRANCH' }
def lineCounter = counters.find { it.@type == 'LINE' }
def methodCounter = counters.find { it.@type == 'METHOD' }
def classCounter = counters.find { it.@type == 'CLASS' }
def calcCoverage = { counter ->
if (counter == null) return "N/A"
def missed = counter.@missed.toInteger()
def covered = counter.@covered.toInteger()
def total = missed + covered
if (total == 0) return "N/A"
return String.format("%.1f%%", (covered * 100.0) / total)
}
println ""
println "═══════════════════════════════════════════════════════════════"
println " Code Coverage Report"
println "═══════════════════════════════════════════════════════════════"
println " Instructions: ${calcCoverage(instructionCounter)}"
println " Branches: ${calcCoverage(branchCounter)}"
println " Lines: ${calcCoverage(lineCounter)}"
println " Methods: ${calcCoverage(methodCounter)}"
println " Classes: ${calcCoverage(classCounter)}"
println "═══════════════════════════════════════════════════════════════"
println " Full report: file://${layout.buildDirectory.get()}/reports/jacoco/test/html/index.html"
println "═══════════════════════════════════════════════════════════════"
}
}
}
def isNonStable = { String version ->
def stableKeyword = ["RELEASE", "FINAL", "GA"].any { it -> version.toUpperCase().contains(it) }
def regex = /^[0-9,.v-]+(-r)?$/
return !stableKeyword && !(version ==~ regex)
}
tasks.named("dependencyUpdates").configure {
rejectVersionIf {
isNonStable(it.candidate.version)
}
rejectVersionIf {
isNonStable(it.candidate.version) && !isNonStable(it.currentVersion)
}
}
// Available commands:
// -------------------
// 1) Build production: ./gradlew clean bootJar
// 2) Execute tests: ./gradlew cleanTest test
// 3) Check Java code format: ./gradlew spotlessCheck
// 4) Apply Java code formatter: ./gradlew spotlessApply
// 5) Check JavaDoc: ./gradlew checkstyleMain
// 6) Find dependency updates: ./gradlew dependencyUpdates -Drevision=release