Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions buildSrc/call-site-instrumentation-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import com.github.jengelman.gradle.plugins.shadow.transformers.ApacheLicenseResourceTransformer
import com.github.jengelman.gradle.plugins.shadow.transformers.ApacheNoticeResourceTransformer
import org.gradle.api.file.DuplicatesStrategy.INCLUDE

plugins {
java
id("com.diffplug.spotless") version "8.4.0"
Expand Down Expand Up @@ -69,11 +73,11 @@ tasks {
}

shadowJar {
duplicatesStrategy = DuplicatesStrategy.FAIL
// Let's skip license/notice since this jar's only use is during build
filesMatching(listOf("META-INF/LICENSE*", "META-INF/NOTICE*")) {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
duplicatesStrategy = INCLUDE
transform<ApacheLicenseResourceTransformer>()
transform<ApacheNoticeResourceTransformer>()
failOnDuplicateEntries = true
Comment on lines +77 to +79

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: Good idea.


manifest {
attributes(mapOf("Main-Class" to "datadog.trace.plugin.csi.PluginApplication"))
}
Expand Down
31 changes: 16 additions & 15 deletions dd-java-agent/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import static org.gradle.api.file.DuplicatesStrategy.INCLUDE

import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import com.github.jengelman.gradle.plugins.shadow.transformers.PreserveFirstFoundResourceTransformer
import java.util.concurrent.atomic.AtomicBoolean
import java.util.jar.JarFile

Expand Down Expand Up @@ -83,21 +86,19 @@ def generalShadowJarConfig(ShadowJar shadowJarTask) {
mergeServiceFiles()
addMultiReleaseAttribute = false

duplicatesStrategy = DuplicatesStrategy.FAIL
// Service descriptors are intentionally merged by mergeServiceFiles(); let
// duplicate service entries reach that transformer instead of failing first.
filesMatching('META-INF/services/**') {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
// Vendored dependencies often repeat license/notice metadata. Keep one copy
// while still failing on unexpected duplicate runtime resources and classes.
filesMatching([
'META-INF/LICENSE*',
'META-INF/NOTICE*',
'META-INF/AL2.0',
'META-INF/LGPL2.1',
]) {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
// Allow duplicate to merge service files
duplicatesStrategy = INCLUDE
// Ensure there is no duplicate in the final jar after resource transformer applied
failOnDuplicateEntries = true

// Vendored dependencies repeat license/notice metadata; keep a single copy
transform(PreserveFirstFoundResourceTransformer) {
it.include(
'META-INF/LICENSE*',
'META-INF/NOTICE*',
'META-INF/AL2.0',
'META-INF/LGPL2.1',
)
}

// Remove some cruft from the final jar.
Expand Down