-
Notifications
You must be signed in to change notification settings - Fork 844
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
297 lines (269 loc) · 12.8 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
297 lines (269 loc) · 12.8 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
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
import org.apache.tools.ant.filters.ReplaceTokens
import java.nio.file.Path
import java.nio.file.Paths
plugins {
alias(libs.plugins.springDependencyManagement) apply false
alias(libs.plugins.springBoot) apply false
alias(libs.plugins.jacocoLog) apply false
alias(libs.plugins.sonarqube) // Applied to root for global configuration
}
allprojects {
repositories {
mavenCentral()
maven {
url = uri("https://build.shibboleth.net/nexus/content/repositories/releases/")
}
maven {
url = uri("https://repository.mulesoft.org/releases/")
}
}
}
subprojects {
/** Log each test PASSED/SKIPPED/FAILED unless disabled (-PverboseTests=false or UAA_VERBOSE_TESTS=0/off). */
val uaaVerboseTestRaw = (findProperty("verboseTests") ?: System.getenv("UAA_VERBOSE_TESTS") ?: "true")
.toString().trim().lowercase()
val uaaVerboseTestEvents = !listOf("false", "0", "off", "no").contains(uaaVerboseTestRaw)
// Configure Java version for all projects with Java plugin applied
plugins.withType<JavaPlugin> {
configure<JavaPluginExtension> {
sourceCompatibility = JavaVersion.VERSION_25
targetCompatibility = JavaVersion.VERSION_25
}
}
// Use afterEvaluate to access version catalog after project evaluation
afterEvaluate {
// Override Spring Boot managed dependency versions using ext properties
// See: https://docs.spring.io/spring-boot/appendix/dependency-versions/properties.html
extra["tomcat.version"] = libs.versions.tomcat.get()
extra["commons-codec.version"] = libs.versions.commonsCodec.get()
extra["selenium.version"] = libs.versions.selenium.get()
configure<io.spring.gradle.dependencymanagement.dsl.DependencyManagementExtension> {
imports {
mavenBom(libs.springBootBom.get().toString())
}
// Libraries that have version conflicts (not managed by BOMs above)
dependencies {
// Guava - multiple versions from different transitive deps
dependency("com.google.guava:guava:${libs.versions.guava.get()}")
}
}
}
configurations.configureEach {
exclude(group = "org.hamcrest", module = "hamcrest-all")
exclude(group = "org.hamcrest", module = "hamcrest-core")
exclude(group = "org.hamcrest", module = "hamcrest-library")
exclude(group = "org.springframework.boot", module = "spring-boot-starter-logging")
exclude(group = "org.apache.directory.server", module = "apacheds-core")
exclude(group = "org.apache.directory.server", module = "apacheds-protocol-ldap")
exclude(group = "org.skyscreamer", module = "jsonassert")
exclude(group = "com.vaadin.external.google", module = "android-json")
exclude(group = "com.unboundid.components", module = "json")
// Exclude opensaml-security-api and non-FIPS bouncycastle libs, and use Shadow library for FIPS compliance
exclude(group = "org.bouncycastle", module = "bcpkix-jdk15on")
exclude(group = "org.bouncycastle", module = "bcprov-jdk15on")
exclude(group = "org.bouncycastle", module = "bcutil-jdk15on")
exclude(group = "org.bouncycastle", module = "bcprov-jdk18on")
exclude(group = "org.bouncycastle", module = "bcpkix-jdk18on")
exclude(group = "org.bouncycastle", module = "bcutil-jdk18on")
resolutionStrategy {
eachDependency {
// Dependencies not managed by any BOM
// OpenSAML modules - align for migration
if (requested.group == "org.opensaml" && requested.name.startsWith("opensaml-")) {
useVersion(libs.versions.opensaml.get())
because("Pinning all opensaml modules to the same version for OpenSAML 5 migration.")
}
// Cryptacular - avoid regressions, explicit downgrade to 1.2.6
else if (requested.group == "org.cryptacular" && requested.name == "cryptacular") {
useVersion(libs.versions.cryptacular.get())
because("Pinning cryptacular to avoid regressions from newer OpenSAML versions.")
}
}
}
}
tasks.withType<JavaCompile>().configureEach {
options.compilerArgs.addAll(listOf("-Xlint:none", "-nowarn", "-parameters"))
}
tasks.withType<Test>().configureEach {
// when failFast = true AND retry is on, there is a serious issue:
// Gradle might stop the test run due to the failFast but still concludes with BUILD SUCCESSFUL (if the retry is successful)
failFast = false
useJUnitPlatform()
// Increased to 1536m for Spring Boot 4 compatibility
jvmArgs(
"-Xmx1536m",
"-Xms512m",
"-XX:MaxMetaspaceSize=512m",
"-XX:+UseG1GC",
"-XX:+StartAttachListener",
"-XX:+HeapDumpOnOutOfMemoryError",
"-XX:HeapDumpPath=/var/log/uaa-tests.hprof"
)
// Enable test timing to identify slow tests
// This helps debug CI performance issues
reports {
junitXml.required.set(true)
html.required.set(true)
}
testLogging {
if (uaaVerboseTestEvents) {
events("passed", "skipped", "failed")
} else {
events("failed")
}
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
// Set showStandardStreams=true to see all standard output from tests (there's a ton of it!)
showStandardStreams = false
showCauses = true
showExceptions = true
showStackTraces = true
}
// Add system property to enable detailed test timing
systemProperty("junit.jupiter.execution.timeout.default", System.getProperty("junit.jupiter.execution.timeout.default", "0"))
// Log slow tests to help identify bottlenecks
addTestListener(object : TestListener {
override fun beforeSuite(suite: TestDescriptor) {}
override fun beforeTest(testDescriptor: TestDescriptor) {}
override fun afterTest(testDescriptor: TestDescriptor, result: TestResult) {
val duration = result.endTime - result.startTime
if (duration > 10000) { // 10 seconds
logger.warn("SLOW TEST: ${testDescriptor.className}.${testDescriptor.name} took ${duration}ms")
}
}
override fun afterSuite(suite: TestDescriptor, result: TestResult) {
if (suite.parent == null) {
val duration = result.endTime - result.startTime
val testLabel = if (result.testCount == 1L) "unit-test" else "unit-tests"
logger.lifecycle("[${project.name}] Completed ${result.testCount} $testLabel in ${duration}ms (passed=${result.successfulTestCount};failed=${result.failedTestCount};skipped=${result.skippedTestCount})")
}
}
})
}
tasks.register<DependencyReportTask>("allDeps") {}
tasks.register("writeNewPom") {
doLast {
// This task is deprecated - just create a simple POM
file("./pom.xml").writeText("""<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.cloudfoundry.identity</groupId>
<artifactId>cloudfoundry-identity-parent</artifactId>
<version>${version}</version>
<packaging>pom</packaging>
<name>CloudFoundry Identity Parent</name>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
</project>""")
}
}
repositories {
mavenCentral()
maven {
url = uri("https://repo.maven.apache.org/maven2")
}
}
}
configure<org.sonarqube.gradle.SonarExtension> {
properties {
property("sonar.projectKey", "cloudfoundry-identity-parent")
property("sonar.organization", "cloudfoundry-1")
property("sonar.host.url", "https://sonarcloud.io")
property("sonar.exclusions", "samples/**/*.*,**/*Test.java,**/*Tests.java,**/*IT.java,**/*SecurityConfiguration.java")
property("sonar.java.source", JavaVersion.current())
}
}
gradle.taskGraph.whenReady {
allprojects.forEach { proj ->
proj.tasks.withType<Test>().forEach { testTask ->
testTask.systemProperty("spring.profiles.active", System.getProperty("spring.profiles.active", "hsqldb"))
testTask.systemProperty("testId", System.getProperty("testId", ""))
testTask.systemProperty("zones.paths.enabled", System.getProperty("zones.paths.enabled", "true"))
}
}
}
tasks.register<Copy>("manifests") {
dependsOn(subprojects.map { it.tasks.named("assemble") })
from("uaa/src/test/resources/sample-manifests") {
include("**/*.yml")
filter<ReplaceTokens>(
"tokens" to mapOf(
"version" to version,
"app" to System.getProperty("app", "myuaa"),
"appdomain" to System.getProperty("app-domain", "bosh-lite.com")
)
)
}
into("build/sample-manifests")
}
tasks.register("cleanBootTomcatDir") {
doLast {
val tomcatBase = file("scripts/boot/tomcat/").absolutePath
delete(Path.of(tomcatBase))
Paths.get(tomcatBase, "work").toFile().mkdirs()
Paths.get(tomcatBase, "webapps").toFile().mkdirs()
}
}
tasks.register<JavaExec>("bootWarRun") {
dependsOn("cleanBootTomcatDir")
dependsOn(subprojects.map { it.tasks.named("assemble") })
classpath(files(file("uaa/build/libs/cloudfoundry-identity-uaa-0.0.0.war")))
systemProperty("server.tomcat.basedir", file("scripts/boot/tomcat/").absolutePath)
systemProperty("SECRETS_DIR", System.getProperty("SECRETS_DIR", file("scripts/boot").absolutePath))
systemProperty("spring.profiles.active", System.getProperty("spring.profiles.active", "hsqldb"))
systemProperty("metrics.perRequestMetrics", System.getProperty("metrics.perRequestMetrics", "true"))
systemProperty("smtp.host", "localhost")
systemProperty("smtp.port", 2525)
systemProperty("java.security.egd", "file:/dev/./urandom")
systemProperty("CLOUDFOUNDRY_CONFIG_PATH", file("scripts/boot").absolutePath)
systemProperty("server.servlet.context-path", "/uaa")
systemProperty("statsd.enabled", "true")
systemProperty("logging.config", file("scripts/boot/log4j2.properties").absolutePath)
systemProperty("zones.paths.enabled", System.getProperty("zones.paths.enabled", "true"))
}
tasks.register<Exec>("killUaa") {
workingDir("./")
executable = "scripts/kill_uaa.sh"
}
/**
* Writes the resolved tomcat-embed-core version (from the Spring Boot BOM) to
* {@code build/tomcat-distribution.version} for scripts that download a matching
* Apache Tomcat binary distribution (standalone integration tests).
*/
tasks.register("writeTomcatDistributionVersion") {
group = "build"
description = "Writes build/tomcat-distribution.version from tomcat-embed-core on cloudfoundry-identity-uaa runtimeClasspath"
val uaaProject = project(":cloudfoundry-identity-uaa")
val outFile = layout.buildDirectory.file("tomcat-distribution.version")
outputs.file(outFile)
doLast {
val cfg = uaaProject.configurations.named("runtimeClasspath").get()
val artifact = cfg.resolvedConfiguration.resolvedArtifacts.find { it.name == "tomcat-embed-core" }
if (artifact == null) {
throw GradleException("Could not resolve tomcat-embed-core version from :cloudfoundry-identity-uaa runtimeClasspath")
}
outFile.get().asFile.parentFile.mkdirs()
outFile.get().asFile.writeText(artifact.moduleVersion.id.version)
}
}
tasks.register("printTomcatDistributionVersion") {
group = "help"
description = "Prints the Apache Tomcat version matching Spring Boot embedded tomcat-embed-core"
dependsOn("writeTomcatDistributionVersion")
doLast {
println(file("${layout.buildDirectory.get().asFile}/tomcat-distribution.version").readText().trim())
}
}
tasks.register("run") {
dependsOn("killUaa")
dependsOn(":cloudfoundry-identity-uaa:bootRun")
description = "Kills any running UAA and starts the application. Use -Pdebug to enable debug mode (starts immediately) or -Pdebugs to enable debug mode with suspend (waits for debugger). Default port 5005, configurable with -PdebugPort=<port>"
group = "application"
}