Skip to content

Commit de287c2

Browse files
authored
Fix duplicate entries (#2352)
1 parent ca58ba4 commit de287c2

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

agent/agent/build.gradle.kts

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,21 @@ tasks {
8888

8989
// 3. the relocated and isolated javaagent libs are merged together with the bootstrap libs (which undergo relocation
9090
// in this task) and the upstream javaagent jar; duplicates are removed
91-
shadowJar {
91+
val shadowJarWithDuplicates by registering(ShadowJar::class) {
9292
configurations = listOf(bootstrapLibs, upstreamAgent)
9393

94+
// using logback in this distro
95+
// this excludes slf4j-simple from the upstream agent
96+
// but it doesn't exclude logback's files in this package since they haven't been shaded
97+
// into this package yet at the time exclusion takes place
98+
exclude("io/opentelemetry/javaagent/slf4j/impl/**")
99+
94100
dependsOn(isolateJavaagentLibs)
95101
from(isolateJavaagentLibs.get().outputs)
96102

97103
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
98104

99-
archiveClassifier.set("")
105+
archiveClassifier.set("dontuse")
100106

101107
manifest {
102108
attributes(jar.get().manifest.attributes)
@@ -109,9 +115,21 @@ tasks {
109115
}
110116
}
111117

118+
// a separate task is needed to get rid of duplicates
119+
shadowJar {
120+
archiveClassifier.set("")
121+
122+
dependsOn(shadowJarWithDuplicates)
123+
124+
from(zipTree(shadowJarWithDuplicates.get().archiveFile))
125+
126+
manifest {
127+
attributes(shadowJarWithDuplicates.get().manifest.attributes)
128+
}
129+
}
130+
112131
jar {
113-
// Empty jar that cannot be used for anything and isn't published.
114-
archiveClassifier.set("dontuse")
132+
enabled = false
115133
}
116134

117135
assemble {

buildSrc/src/main/kotlin/ai.shadow-conventions.gradle.kts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ tasks.withType<ShadowJar>().configureEach {
1111

1212
exclude("**/module-info.class")
1313

14-
// using logback in this distro
15-
exclude("io/opentelemetry/javaagent/slf4j/impl/**")
16-
1714
// Prevents conflict with other SLF4J instances. Important for premain.
1815
relocate("org.slf4j", "io.opentelemetry.javaagent.slf4j")
1916
// rewrite dependencies calling Logger.getLogger

0 commit comments

Comments
 (0)