@@ -46,73 +46,75 @@ dependencies {
46
46
* This general config is shared by all of them
47
47
*/
48
48
49
- ext. generalShadowJarConfig = {
50
- mergeServiceFiles()
51
-
52
- duplicatesStrategy = DuplicatesStrategy . FAIL
53
-
54
- // Include AgentPreCheck compiled with Java 6.
55
- from sourceSets. main_java6. output
56
-
57
- // Remove some cruft from the final jar.
58
- // These patterns should NOT include **/META-INF/maven/**/pom.properties, which is
59
- // used to report our own dependencies, but we should remove the top-level metadata
60
- // of vendored packages because those could trigger unwanted framework checks.
61
- exclude ' /META-INF/maven/org.slf4j/**'
62
- exclude ' /META-INF/maven/org.snakeyaml/**'
63
- exclude ' **/META-INF/maven/**/pom.xml'
64
- exclude ' **/META-INF/proguard/'
65
- exclude ' **/META-INF/*.kotlin_module'
66
- exclude ' **/module-info.class'
67
- exclude ' **/liblz4-java.so'
68
- exclude ' **/liblz4-java.dylib'
69
- exclude ' **/inst/META-INF/versions/**'
70
- exclude ' **/META-INF/versions/*/org/yaml/**'
71
-
72
- // Replaced by 'instrumenter.index', no need to include original service file
73
- exclude ' **/META-INF/services/datadog.trace.agent.tooling.InstrumenterModule'
74
-
75
- // Prevents conflict with other SLF4J instances. Important for premain.
76
- relocate ' org.slf4j' , ' datadog.slf4j'
77
- // Prevent conflicts with flat class-path when using GraalVM native-images
78
- relocate ' org.jctools' , ' datadog.jctools'
79
- relocate ' net.jpountz' , ' datadog.jpountz'
80
- // rewrite dependencies calling Logger.getLogger
81
- relocate ' java.util.logging.Logger' , ' datadog.trace.bootstrap.PatchLogger'
82
- // patch JFFI loading mechanism to maintain isolation
83
- exclude ' **/com/kenai/jffi/Init.class'
84
- relocate(' com.kenai.jffi.Init' , ' com.kenai.jffi.PatchInit' )
85
-
86
- // Minimize and relocate the airlift compressor dependency for ZSTD
87
- exclude ' **/io/airlift/compress/bzip2/**'
88
- exclude ' **/io/airlift/compress/deflate/**'
89
- exclude ' **/io/airlift/compress/gzip/**'
90
- exclude ' **/io/airlift/compress/hadoop/**'
91
- exclude ' **/io/airlift/compress/lz4/**'
92
- exclude ' **/io/airlift/compress/lzo/**'
93
- exclude ' **/io/airlift/compress/snappy/**'
94
- relocate ' io.airlift' , ' datadog.io.airlift'
95
-
96
- final String projectName = " ${ project.name} "
97
-
98
- // Prevents conflict with other instances, but doesn't relocate instrumentation
99
- if (! projectName. equals(' instrumentation' )) {
100
- relocate ' org.snakeyaml.engine' , ' datadog.snakeyaml.engine'
101
- relocate ' okhttp3' , ' datadog.okhttp3'
102
- relocate ' okio' , ' datadog.okio'
103
- }
49
+ def generalShadowJarConfig (ShadowJar shadowJarTask ) {
50
+ shadowJarTask. with {
51
+ mergeServiceFiles()
52
+
53
+ duplicatesStrategy = DuplicatesStrategy . FAIL
54
+
55
+ // Include AgentPreCheck compiled with Java 6.
56
+ from sourceSets. main_java6. output
57
+
58
+ // Remove some cruft from the final jar.
59
+ // These patterns should NOT include **/META-INF/maven/**/pom.properties, which is
60
+ // used to report our own dependencies, but we should remove the top-level metadata
61
+ // of vendored packages because those could trigger unwanted framework checks.
62
+ exclude ' /META-INF/maven/org.slf4j/**'
63
+ exclude ' /META-INF/maven/org.snakeyaml/**'
64
+ exclude ' **/META-INF/maven/**/pom.xml'
65
+ exclude ' **/META-INF/proguard/'
66
+ exclude ' **/META-INF/*.kotlin_module'
67
+ exclude ' **/module-info.class'
68
+ exclude ' **/liblz4-java.so'
69
+ exclude ' **/liblz4-java.dylib'
70
+ exclude ' **/inst/META-INF/versions/**'
71
+ exclude ' **/META-INF/versions/*/org/yaml/**'
72
+
73
+ // Replaced by 'instrumenter.index', no need to include original service file
74
+ exclude ' **/META-INF/services/datadog.trace.agent.tooling.InstrumenterModule'
75
+
76
+ // Prevents conflict with other SLF4J instances. Important for premain.
77
+ relocate ' org.slf4j' , ' datadog.slf4j'
78
+ // Prevent conflicts with flat class-path when using GraalVM native-images
79
+ relocate ' org.jctools' , ' datadog.jctools'
80
+ relocate ' net.jpountz' , ' datadog.jpountz'
81
+ // rewrite dependencies calling Logger.getLogger
82
+ relocate ' java.util.logging.Logger' , ' datadog.trace.bootstrap.PatchLogger'
83
+ // patch JFFI loading mechanism to maintain isolation
84
+ exclude ' **/com/kenai/jffi/Init.class'
85
+ relocate(' com.kenai.jffi.Init' , ' com.kenai.jffi.PatchInit' )
86
+
87
+ // Minimize and relocate the airlift compressor dependency for ZSTD
88
+ exclude ' **/io/airlift/compress/bzip2/**'
89
+ exclude ' **/io/airlift/compress/deflate/**'
90
+ exclude ' **/io/airlift/compress/gzip/**'
91
+ exclude ' **/io/airlift/compress/hadoop/**'
92
+ exclude ' **/io/airlift/compress/lz4/**'
93
+ exclude ' **/io/airlift/compress/lzo/**'
94
+ exclude ' **/io/airlift/compress/snappy/**'
95
+ relocate ' io.airlift' , ' datadog.io.airlift'
96
+
97
+ final String projectName = " ${ project.name} "
98
+
99
+ // Prevents conflict with other instances, but doesn't relocate instrumentation
100
+ if (! projectName. equals(' instrumentation' )) {
101
+ relocate ' org.snakeyaml.engine' , ' datadog.snakeyaml.engine'
102
+ relocate ' okhttp3' , ' datadog.okhttp3'
103
+ relocate ' okio' , ' datadog.okio'
104
+ }
104
105
105
- if (! project. hasProperty(" disableShadowRelocate" ) || ! disableShadowRelocate) {
106
- // shadow OT impl to prevent casts to implementation
107
- relocate ' datadog.trace.common' , ' datadog.trace.agent.common'
108
- relocate ' datadog.trace.core' , ' datadog.trace.agent.core'
109
- relocate ' datadog.opentracing' , ' datadog.trace.agent.ot'
110
- // shadow things in internal API that has slf4j in the API and is accessed from core
111
- relocate ' datadog.trace.relocate' , ' datadog.trace.agent.relocate'
106
+ if (! project. hasProperty(" disableShadowRelocate" ) || ! disableShadowRelocate) {
107
+ // shadow OT impl to prevent casts to implementation
108
+ relocate ' datadog.trace.common' , ' datadog.trace.agent.common'
109
+ relocate ' datadog.trace.core' , ' datadog.trace.agent.core'
110
+ relocate ' datadog.opentracing' , ' datadog.trace.agent.ot'
111
+ // shadow things in internal API that has slf4j in the API and is accessed from core
112
+ relocate ' datadog.trace.relocate' , ' datadog.trace.agent.relocate'
113
+ }
112
114
}
113
115
}
114
116
115
- def includeShadowJar (TaskProvider<ShadowJar > shadowJarTask , String jarname ) {
117
+ def includeShadowJar (TaskProvider<ShadowJar > includedShadowJarTask , String destinationDir ) {
116
118
def opentracingFound = new AtomicBoolean ()
117
119
project. processResources {
118
120
doFirst {
@@ -129,12 +131,12 @@ def includeShadowJar(TaskProvider<ShadowJar> shadowJarTask, String jarname) {
129
131
}
130
132
}
131
133
132
- from(zipTree(shadowJarTask . get() . archiveFile)) {
133
- into jarname
134
+ from(zipTree(includedShadowJarTask . map { it . archiveFile } )) {
135
+ into destinationDir
134
136
rename ' (^.*)\\ .class$' , ' $1.classdata'
135
137
// Rename LICENSE file since it clashes with license dir on non-case sensitive FSs (i.e. Mac)
136
138
rename ' ^LICENSE$' , ' LICENSE.renamed'
137
- if (jarname == ' inst' ) {
139
+ if (destinationDir == ' inst' ) {
138
140
// byte-buddy now ships classes optimized for Java8+ under META-INF/versions/9
139
141
// since we target Java8+ we can promote these classes over the pre-Java8 ones
140
142
duplicatesStrategy = DuplicatesStrategy . EXCLUDE
@@ -148,27 +150,29 @@ def includeShadowJar(TaskProvider<ShadowJar> shadowJarTask, String jarname) {
148
150
}
149
151
150
152
project. tasks. named(" processResources" ) {
151
- dependsOn shadowJarTask
153
+ dependsOn includedShadowJarTask
154
+ }
155
+
156
+ includedShadowJarTask. configure {
157
+ generalShadowJarConfig(it as ShadowJar )
152
158
}
153
- shadowJarTask. configure generalShadowJarConfig
154
159
}
155
160
156
- def includeSubprojShadowJar (String projName , String jarname ) {
157
- evaluationDependsOn projName
158
- def proj = project(projName)
159
- includeShadowJar proj. tasks. named(" shadowJar" ), jarname
161
+ def includeSubprojShadowJar (Project includedProjectJar , String destinationDir ) {
162
+ evaluationDependsOn(includedProjectJar. path)
163
+ includeShadowJar(includedProjectJar. tasks. named(" shadowJar" , ShadowJar ), destinationDir)
160
164
}
161
165
162
- includeSubprojShadowJar ' :dd-java-agent:instrumentation' , ' inst'
163
- includeSubprojShadowJar ' :dd-java-agent:agent-jmxfetch' , ' metrics'
164
- includeSubprojShadowJar ' :dd-java-agent:agent-profiling' , ' profiling'
165
- includeSubprojShadowJar ' :dd-java-agent:appsec' , ' appsec'
166
- includeSubprojShadowJar ' :dd-java-agent:agent-iast' , ' iast'
167
- includeSubprojShadowJar ' :dd-java-agent:agent-debugger' , ' debugger'
168
- includeSubprojShadowJar ' :dd-java-agent:agent-ci-visibility' , ' ci-visibility'
169
- includeSubprojShadowJar ' :dd-java-agent:agent-llmobs' , ' llm-obs'
170
- includeSubprojShadowJar ' :dd-java-agent:agent-logs-intake' , ' logs-intake'
171
- includeSubprojShadowJar ' :dd-java-agent:cws-tls' , ' cws-tls'
166
+ includeSubprojShadowJar(project( ' :dd-java-agent:instrumentation' ) , ' inst' )
167
+ includeSubprojShadowJar(project( ' :dd-java-agent:agent-jmxfetch' ) , ' metrics' )
168
+ includeSubprojShadowJar(project( ' :dd-java-agent:agent-profiling' ) , ' profiling' )
169
+ includeSubprojShadowJar(project( ' :dd-java-agent:appsec' ) , ' appsec' )
170
+ includeSubprojShadowJar(project( ' :dd-java-agent:agent-iast' ) , ' iast' )
171
+ includeSubprojShadowJar(project( ' :dd-java-agent:agent-debugger' ) , ' debugger' )
172
+ includeSubprojShadowJar(project( ' :dd-java-agent:agent-ci-visibility' ) , ' ci-visibility' )
173
+ includeSubprojShadowJar(project( ' :dd-java-agent:agent-llmobs' ) , ' llm-obs' )
174
+ includeSubprojShadowJar(project( ' :dd-java-agent:agent-logs-intake' ) , ' logs-intake' )
175
+ includeSubprojShadowJar(project( ' :dd-java-agent:cws-tls' ) , ' cws-tls' )
172
176
173
177
def sharedShadowJar = tasks. register(' sharedShadowJar' , ShadowJar ) {
174
178
configurations = [project. configurations. sharedShadowInclude]
@@ -200,7 +204,9 @@ def traceShadowJar = tasks.register('traceShadowJar', ShadowJar) {
200
204
}
201
205
includeShadowJar(traceShadowJar, ' trace' )
202
206
203
- shadowJar generalShadowJarConfig >> {
207
+ tasks. named(" shadowJar" , ShadowJar ) {
208
+ generalShadowJarConfig(it)
209
+
204
210
configurations = [project. configurations. shadowInclude]
205
211
206
212
archiveClassifier = ' '
@@ -352,7 +358,7 @@ tasks.register('checkAgentJarSize') {
352
358
doLast {
353
359
// Arbitrary limit to prevent unintentional increases to the agent jar size
354
360
// Raise or lower as required
355
- assert shadowJar. archiveFile. get(). getAsFile(). length() <= 32 * 1024 * 1024
361
+ assert tasks . named( " shadowJar" , ShadowJar ) . get() . archiveFile. get(). getAsFile(). length() <= 32 * 1024 * 1024
356
362
}
357
363
358
364
dependsOn " shadowJar"
0 commit comments