@@ -75,7 +75,6 @@ testing {
7575 targets.all {
7676 testTask.configure {
7777 dependsOn(tasks.shadowJar)
78- dependsOn(tasks.named(" copyAgent" ))
7978
8079 // include only the integration test file
8180 include(" io/opentelemetry/contrib/gcp/auth/GcpAuthExtensionEndToEndTest.class" )
@@ -84,21 +83,27 @@ testing {
8483
8584 environment(" GOOGLE_CLOUD_QUOTA_PROJECT" , " quota-project-id" )
8685 environment(" GOOGLE_APPLICATION_CREDENTIALS" , fakeCredsFilePath)
87- jvmArgs(
88- " -javaagent:$javaAgentJarPath " ,
89- " -Dotel.javaagent.extensions=$authExtensionJarPath " ,
90- " -Dgoogle.cloud.project=my-gcp-project" ,
91- " -Dotel.java.global-autoconfigure.enabled=true" ,
92- " -Dotel.exporter.otlp.endpoint=http://localhost:4318" ,
93- " -Dotel.resource.providers.gcp.enabled=true" ,
94- " -Dotel.traces.exporter=otlp" ,
95- " -Dotel.bsp.schedule.delay=2000" ,
96- " -Dotel.metrics.exporter=none" ,
97- " -Dotel.logs.exporter=none" ,
98- " -Dotel.exporter.otlp.protocol=http/protobuf" ,
99- " -Dotel.javaagent.debug=false" ,
100- " -Dmockserver.logLevel=trace"
101- )
86+
87+ val agentJar = configurations.named(" agent" ).map { it.singleFile.absolutePath }
88+ val extensionJarPath = tasks.shadowJar.flatMap { it.archiveFile }.map { it.asFile.absolutePath }
89+
90+ jvmArgumentProviders.add(CommandLineArgumentProvider {
91+ listOf (
92+ " -javaagent:${agentJar.get()} " ,
93+ " -Dotel.javaagent.extensions=${extensionJarPath.get()} " ,
94+ " -Dgoogle.cloud.project=my-gcp-project" ,
95+ " -Dotel.java.global-autoconfigure.enabled=true" ,
96+ " -Dotel.exporter.otlp.endpoint=http://localhost:4318" ,
97+ " -Dotel.resource.providers.gcp.enabled=true" ,
98+ " -Dotel.traces.exporter=otlp" ,
99+ " -Dotel.bsp.schedule.delay=2000" ,
100+ " -Dotel.metrics.exporter=none" ,
101+ " -Dotel.logs.exporter=none" ,
102+ " -Dotel.exporter.otlp.protocol=http/protobuf" ,
103+ " -Dotel.javaagent.debug=false" ,
104+ " -Dmockserver.logLevel=trace"
105+ )
106+ })
102107 }
103108 }
104109 }
@@ -133,14 +138,3 @@ tasks {
133138 dependsOn(shadowJar)
134139 }
135140}
136-
137- val builtLibsDir = layout.buildDirectory.dir(" libs" ).get().asFile.absolutePath
138- val javaAgentJarPath = " $builtLibsDir /otel-agent.jar"
139- val authExtensionJarPath = " ${tasks.shadowJar.get().archiveFile.get()} "
140-
141- tasks.register<Copy >(" copyAgent" ) {
142- into(layout.buildDirectory.dir(" libs" ))
143- from(configurations.named(" agent" ) {
144- rename(" opentelemetry-javaagent(.*).jar" , " otel-agent.jar" )
145- })
146- }
0 commit comments