2
0
Fork 0
mirror of https://github.com/ethauvin/rife2-hello.git synced 2025-04-25 23:37:12 -07:00

Made tests use the java agent

This commit is contained in:
Geert Bevin 2023-02-13 09:35:07 -05:00
parent 44637cc6fc
commit d375b99c48

View file

@ -38,7 +38,14 @@ dependencies {
} }
tasks { tasks {
named<Test>("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() useJUnitPlatform()
testLogging { testLogging {
exceptionFormat = TestExceptionFormat.FULL exceptionFormat = TestExceptionFormat.FULL
@ -71,9 +78,6 @@ tasks {
register<JavaExec>("run") { register<JavaExec>("run") {
classpath = sourceSets["main"].runtimeClasspath classpath = sourceSets["main"].runtimeClasspath
mainClass.set("hello.App") 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") jvmArgs = listOf("-javaagent:$rifeAgentJar")
} }
@ -92,11 +96,10 @@ tasks {
manifest { manifest {
attributes["Main-Class"] = "hello.AppUber" attributes["Main-Class"] = "hello.AppUber"
} }
val dependencies = configurations val uberDependencies = dependencies
.runtimeClasspath.get() .filter { !it.toString().matches("rife2-.*agent\\.jar".toRegex()) }
.exclude("**/rife2*-agent.jar")
.map(::zipTree) .map(::zipTree)
from(dependencies, "$buildDir/webapp") from(uberDependencies, "$buildDir/webapp")
with(jar.get()) with(jar.get())
} }
} }