@@ -10,8 +10,6 @@ def otelInstrumentationApiVersion = '2.4.0'
1010apply from : " $rootDir /gradle/java.gradle"
1111apply plugin : ' dd-trace-java.build-time-instrumentation'
1212
13- def otelUnpackedDir = layout. buildDirectory. dir(" otel-unpacked" )
14-
1513configurations {
1614 def ec = register(' embeddedClasspath' ) {
1715 visible = false
@@ -30,9 +28,26 @@ configurations {
3028 }
3129}
3230
31+ // Unpack the embeddedClasspath jars into otelUnpackedDir so that OtelShimGradlePlugin can
32+ // instrument them (e.g. inject the OTel shim).
33+ def unpackOtelJars = tasks. register(' unpackOtelJars' , Sync ) {
34+ exclude ' META-INF/'
35+ exclude ' **/module-info.class'
36+ exclude ' **/package-info.class'
37+
38+ from(configurations. named(' embeddedClasspath' ). map {
39+ it. collect {
40+ zipTree(it)
41+ }
42+ })
43+ // Note: they are intentionally kept in a separate directory from compileJava's output so that
44+ // Gradle's stale-output cleanup on a full rebuild does not delete them before instrumentation.
45+ into layout. buildDirectory. dir(" otel-unpacked" )
46+ }
47+
3348buildTimeInstrumentation {
3449 plugins. addAll(' datadog.opentelemetry.tooling.shim.OtelShimGradlePlugin' )
35- includeClassDirectories. from(otelUnpackedDir )
50+ includeClassDirectories. from(unpackOtelJars )
3651}
3752
3853minimumInstructionCoverage = 0.0
@@ -59,30 +74,6 @@ dependencies {
5974
6075 compileOnly project(' :dd-java-agent:agent-bootstrap' )
6176 implementation project(' :dd-java-agent:agent-otel:otel-shim' )
62-
63- // buildTimeInstrumentationPlugin project(path: ':dd-java-agent:agent-otel:otel-tooling', configuration: 'buildTimeInstrumentationToolingPlugins')
64- }
65-
66- // Unpack the embeddedClasspath jars into otelUnpackedDir so that OtelShimGradlePlugin can
67- // instrument them (e.g. inject the OTel shim).
68- tasks. register(' unpackOtelJars' , Copy ) {
69- dependsOn configurations. named(' embeddedClasspath' )
70- exclude ' META-INF/'
71- exclude ' **/module-info.class'
72- exclude ' **/package-info.class'
73-
74- from(configurations. named(' embeddedClasspath' ). map {
75- it. collect {
76- zipTree(it)
77- }
78- })
79- // Note: they are intentionally kept in a separate directory from compileJava's output so that
80- // Gradle's stale-output cleanup on a full rebuild does not delete them before instrumentation.
81- into otelUnpackedDir
82- }
83-
84- tasks. named(' compileJava' ) {
85- dependsOn ' unpackOtelJars'
8677}
8778
8879tasks. named(" shadowJar" , ShadowJar ) {
0 commit comments