From d375b99c48ae58924d751c143fb6e60731d64cce Mon Sep 17 00:00:00 2001 From: Geert Bevin Date: Mon, 13 Feb 2023 09:35:07 -0500 Subject: [PATCH] Made tests use the java agent --- app/build.gradle.kts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index b7a96de..decccde 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -38,7 +38,14 @@ dependencies { } tasks { - named("test") { + val dependencies = configurations + .runtimeClasspath.get().files; + val rifeAgentJar = dependencies + .filter { it.toString().contains("rife2") } + .filter { it.toString().endsWith("-agent.jar") }[0] + + test { + jvmArgs = listOf("-javaagent:$rifeAgentJar") useJUnitPlatform() testLogging { exceptionFormat = TestExceptionFormat.FULL @@ -71,9 +78,6 @@ tasks { register("run") { classpath = sourceSets["main"].runtimeClasspath mainClass.set("hello.App") - val rifeAgentJar = configurations.runtimeClasspath.get().files - .filter { it.toString().contains("rife2") } - .filter { it.toString().endsWith("-agent.jar") }[0] jvmArgs = listOf("-javaagent:$rifeAgentJar") } @@ -92,11 +96,10 @@ tasks { manifest { attributes["Main-Class"] = "hello.AppUber" } - val dependencies = configurations - .runtimeClasspath.get() - .exclude("**/rife2*-agent.jar") + val uberDependencies = dependencies + .filter { !it.toString().matches("rife2-.*agent\\.jar".toRegex()) } .map(::zipTree) - from(dependencies, "$buildDir/webapp") + from(uberDependencies, "$buildDir/webapp") with(jar.get()) } } \ No newline at end of file