diff --git a/build.gradle b/build.gradle index b3f01bff8d1..e22ba8de30e 100644 --- a/build.gradle +++ b/build.gradle @@ -148,6 +148,29 @@ allprojects { resolutionStrategy.force 'commons-io:commons-io:2.15.0' resolutionStrategy.force 'org.yaml:snakeyaml:2.2' } + + configurations { + agent + } + + dependencies { + } + + task prepareAgent(type: Copy) { + from(configurations.agent) + into "$buildDir/agent" + } + + dependencies { + agent "org.opensearch:opensearch-agent-bootstrap:${opensearch_version}" + agent "org.opensearch:opensearch-agent:${opensearch_version}" + agent "net.bytebuddy:byte-buddy:${versions.bytebuddy}" + } + + tasks.withType(Test) { + dependsOn prepareAgent + jvmArgs += ["-javaagent:" + project.layout.buildDirectory.file("agent/opensearch-agent-${opensearch_version}.jar").get()] + } } subprojects {