From 63c6b42337be3bac9a2fa78f66c081cdbe51cfa3 Mon Sep 17 00:00:00 2001 From: Nikita Tkachenko <121111529+nikita-tkachenko-datadog@users.noreply.github.com> Date: Mon, 6 Nov 2023 10:33:28 +0100 Subject: [PATCH] Fix forked JVM args duplication when auto-configuring Gradle test tasks (#6151) --- .../instrumentation/gradle/GradleProjectConfigurator.groovy | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dd-java-agent/instrumentation/gradle/src/main/groovy/datadog/trace/instrumentation/gradle/GradleProjectConfigurator.groovy b/dd-java-agent/instrumentation/gradle/src/main/groovy/datadog/trace/instrumentation/gradle/GradleProjectConfigurator.groovy index 650f578e893..1cc1556d42a 100644 --- a/dd-java-agent/instrumentation/gradle/src/main/groovy/datadog/trace/instrumentation/gradle/GradleProjectConfigurator.groovy +++ b/dd-java-agent/instrumentation/gradle/src/main/groovy/datadog/trace/instrumentation/gradle/GradleProjectConfigurator.groovy @@ -75,7 +75,9 @@ class GradleProjectConfigurator { jvmArgs.add("-javaagent:" + config.ciVisibilityAgentJarFile.toPath()) - task.jvmArgs(jvmArgs) + // be sure to use setJvmArgs() and not jvmArgs() + // as the latter will add the arguments rather than replacing them + task.setJvmArgs(jvmArgs) } private static final Pattern PROJECT_PROPERTY_REFERENCE = Pattern.compile("\\\$\\{([^}]+)\\}")