File tree Expand file tree Collapse file tree
buildSrc/call-site-instrumentation-plugin Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import com.github.jengelman.gradle.plugins.shadow.transformers.ApacheLicenseResourceTransformer
2+ import com.github.jengelman.gradle.plugins.shadow.transformers.ApacheNoticeResourceTransformer
3+ import org.gradle.api.file.DuplicatesStrategy.INCLUDE
4+
15plugins {
26 java
37 id(" com.diffplug.spotless" ) version " 8.4.0"
@@ -69,11 +73,11 @@ tasks {
6973 }
7074
7175 shadowJar {
72- duplicatesStrategy = DuplicatesStrategy . FAIL
73- // Let's skip license/notice since this jar's only use is during build
74- filesMatching( listOf ( " META-INF/LICENSE* " , " META-INF/NOTICE* " )) {
75- duplicatesStrategy = DuplicatesStrategy . EXCLUDE
76- }
76+ duplicatesStrategy = INCLUDE
77+ transform< ApacheLicenseResourceTransformer >()
78+ transform< ApacheNoticeResourceTransformer >()
79+ failOnDuplicateEntries = true
80+
7781 manifest {
7882 attributes(mapOf (" Main-Class" to " datadog.trace.plugin.csi.PluginApplication" ))
7983 }
Original file line number Diff line number Diff line change 1+ import static org.gradle.api.file.DuplicatesStrategy.INCLUDE
2+
13import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
4+ import com.github.jengelman.gradle.plugins.shadow.transformers.PreserveFirstFoundResourceTransformer
25import java.util.concurrent.atomic.AtomicBoolean
36import java.util.jar.JarFile
47
@@ -83,21 +86,19 @@ def generalShadowJarConfig(ShadowJar shadowJarTask) {
8386 mergeServiceFiles()
8487 addMultiReleaseAttribute = false
8588
86- duplicatesStrategy = DuplicatesStrategy . FAIL
87- // Service descriptors are intentionally merged by mergeServiceFiles(); let
88- // duplicate service entries reach that transformer instead of failing first.
89- filesMatching(' META-INF/services/**' ) {
90- duplicatesStrategy = DuplicatesStrategy . INCLUDE
91- }
92- // Vendored dependencies often repeat license/notice metadata. Keep one copy
93- // while still failing on unexpected duplicate runtime resources and classes.
94- filesMatching([
95- ' META-INF/LICENSE*' ,
96- ' META-INF/NOTICE*' ,
97- ' META-INF/AL2.0' ,
98- ' META-INF/LGPL2.1' ,
99- ]) {
100- duplicatesStrategy = DuplicatesStrategy . EXCLUDE
89+ // Allow duplicate to merge service files
90+ duplicatesStrategy = INCLUDE
91+ // Ensure there is no duplicate in the final jar after resource transformer applied
92+ failOnDuplicateEntries = true
93+
94+ // Vendored dependencies repeat license/notice metadata; keep a single copy
95+ transform(PreserveFirstFoundResourceTransformer ) {
96+ it. include(
97+ ' META-INF/LICENSE*' ,
98+ ' META-INF/NOTICE*' ,
99+ ' META-INF/AL2.0' ,
100+ ' META-INF/LGPL2.1' ,
101+ )
101102 }
102103
103104 // Remove some cruft from the final jar.
You can’t perform that action at this time.
0 commit comments