From 9f921d40484ac51f9296a53d4d3f3ef74e34d1c3 Mon Sep 17 00:00:00 2001 From: Duane May Date: Fri, 5 Jun 2026 11:32:15 -0400 Subject: [PATCH] Call helper function for `killUaa` task --- uaa/build.gradle.kts | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/uaa/build.gradle.kts b/uaa/build.gradle.kts index 0eb10fc6ae6..6d7e9038e89 100644 --- a/uaa/build.gradle.kts +++ b/uaa/build.gradle.kts @@ -1,3 +1,6 @@ +import org.gradle.process.ExecOperations +import javax.inject.Inject + val identityServer = parent!!.subprojects.find { "cloudfoundry-identity-server" == it.name }!! plugins { @@ -239,11 +242,25 @@ tasks.named("boot } } +interface InjectedExecOps { + @get:Inject val execOps: ExecOperations +} + tasks.register("integrationTest") { // Use the test source set and classpath testClassesDirs = sourceSets.test.get().output.classesDirs classpath = sourceSets.test.get().runtimeClasspath + val injected = project.objects.newInstance() + + // Helper function to kill UAA process + fun killUaa() { + injected.execOps.exec { + workingDir = rootProject.projectDir + executable = "scripts/kill_uaa.sh" + } + } + filter { includeTestsMatching("org.cloudfoundry.identity.uaa.integration.*") includeTestsMatching("*IT") @@ -266,7 +283,7 @@ tasks.register("integrationTest") { return@doFirst } logger.lifecycle("Killing UAA before auto-start") - rootProject.tasks.named("killUaa").get().actions.forEach { it.execute(rootProject.tasks.named("killUaa").get()) } + killUaa() val bootPidFile = rootProject.file("build/boot.pid") val bootLogFile = rootProject.file("build/boot.log") @@ -303,7 +320,7 @@ tasks.register("integrationTest") { } logger.lifecycle("Killing UAA after failed auto-start") - rootProject.tasks.named("killUaa").get().actions.forEach { it.execute(rootProject.tasks.named("killUaa").get()) } + killUaa() throw GradleException("UAA failed to start within $maxWaitSeconds seconds. Check ${bootLogFile.absolutePath}") } @@ -313,7 +330,7 @@ tasks.register("integrationTest") { return@doLast } logger.lifecycle("Stopping UAA application...") - rootProject.tasks.named("killUaa").get().actions.forEach { it.execute(rootProject.tasks.named("killUaa").get()) } + killUaa() rootProject.file("build/boot.pid").delete() }