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
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,18 @@ plugins {
// NOTE: any modifications below should also be made in
// io.opentelemetry.instrumentation.muzzle-check.gradle.kts
tasks.withType<ShadowJar>().configureEach {
// mergeServiceFiles requires that duplicate strategy is set to include
duplicatesStrategy = DuplicatesStrategy.INCLUDE
mergeServiceFiles()
// mergeServiceFiles requires that duplicate strategy is set to include
filesMatching("META-INF/services/**") {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
// Merge any AWS SDK service files that may be present (too bad they didn't just use normal
// service loader...)
mergeServiceFiles("software/amazon/awssdk/global/handlers")
// mergeServiceFiles requires that duplicate strategy is set to include
filesMatching("software/amazon/awssdk/global/handlers/**") {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}

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

Expand Down
17 changes: 11 additions & 6 deletions examples/distro/agent/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ CopySpec isolateClasses(Iterable<File> jars) {
from(zipTree(it)) {
into("inst")
rename("^(.*)\\.class\$", "\$1.classdata")
// Rename LICENSE file since it clashes with license dir on non-case sensitive FSs (i.e. Mac)
rename("^LICENSE\$", "LICENSE.renamed")
exclude("^LICENSE\$")
exclude("META-INF/INDEX.LIST")
exclude("META-INF/*.DSA")
exclude("META-INF/*.SF")
Expand All @@ -66,9 +65,12 @@ tasks {

archiveFileName.set("javaagentLibs-relocated.jar")

// mergeServiceFiles requires that duplicate strategy is set to include
duplicatesStrategy = DuplicatesStrategy.INCLUDE
duplicatesStrategy = DuplicatesStrategy.FAIL
mergeServiceFiles()
// mergeServiceFiles requires that duplicate strategy is set to include
filesMatching("META-INF/services/**") {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
exclude("**/module-info.class")
relocatePackages(it)

Expand Down Expand Up @@ -105,9 +107,12 @@ tasks {

archiveClassifier.set("all")

// mergeServiceFiles requires that duplicate strategy is set to include
duplicatesStrategy = DuplicatesStrategy.INCLUDE
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
mergeServiceFiles("inst/META-INF/services")
// mergeServiceFiles requires that duplicate strategy is set to include
filesMatching("inst/META-INF/services/**") {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}

exclude("**/module-info.class")
relocatePackages(it)
Expand Down
6 changes: 4 additions & 2 deletions examples/distro/gradle/instrumentation.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ dependencies {
shadowJar {
configurations = [project.configurations.runtimeClasspath, project.configurations.testInstrumentation]

// mergeServiceFiles requires that duplicate strategy is set to include
duplicatesStrategy = DuplicatesStrategy.INCLUDE
mergeServiceFiles()
// mergeServiceFiles requires that duplicate strategy is set to include
filesMatching("inst/META-INF/services/**") {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}

archiveFileName = 'agent-testing.jar'

Expand Down
15 changes: 11 additions & 4 deletions examples/distro/testing/agent-for-testing/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,13 @@ tasks {

archiveFileName.set("javaagentLibs-relocated.jar")

// mergeServiceFiles requires that duplicate strategy is set to include
duplicatesStrategy = DuplicatesStrategy.INCLUDE
duplicatesStrategy = DuplicatesStrategy.FAIL
mergeServiceFiles()
// mergeServiceFiles requires that duplicate strategy is set to include
filesMatching("META-INF/services/**") {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}

exclude("**/module-info.class")
relocatePackages(it)

Expand Down Expand Up @@ -100,9 +104,12 @@ tasks {

archiveClassifier.set("")

// mergeServiceFiles requires that duplicate strategy is set to include
duplicatesStrategy = DuplicatesStrategy.INCLUDE
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
mergeServiceFiles("inst/META-INF/services")
// mergeServiceFiles requires that duplicate strategy is set to include
filesMatching("inst/META-INF/services/**") {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}

exclude("**/module-info.class")
relocatePackages(it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,18 @@ val shadowMuzzleBootstrap by tasks.registering(ShadowJar::class) {
// this is a copied from io.opentelemetry.instrumentation.javaagent-shadowing for now at least to
// avoid publishing io.opentelemetry.instrumentation.javaagent-shadowing publicly
tasks.withType<ShadowJar>().configureEach {
// mergeServiceFiles requires that duplicate strategy is set to include
duplicatesStrategy = DuplicatesStrategy.INCLUDE
mergeServiceFiles()
// mergeServiceFiles requires that duplicate strategy is set to include
filesMatching("META-INF/services/**") {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
// Merge any AWS SDK service files that may be present (too bad they didn't just use normal
// service loader...)
mergeServiceFiles("software/amazon/awssdk/global/handlers")
// mergeServiceFiles requires that duplicate strategy is set to include
filesMatching("software/amazon/awssdk/global/handlers/**") {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}

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

Expand Down
10 changes: 7 additions & 3 deletions instrumentation/aws-sdk/aws-sdk-2.2/javaagent/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

plugins {
id("otel.javaagent-instrumentation")
}
Expand Down Expand Up @@ -226,11 +228,13 @@ tasks {
systemProperty("collectMetadata", collectMetadata)
}

withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>().configureEach {
// mergeServiceFiles requires that duplicate strategy is set to include
duplicatesStrategy = DuplicatesStrategy.INCLUDE
withType<ShadowJar>().configureEach {
mergeServiceFiles {
include("software/amazon/awssdk/global/handlers/execution.interceptors")
}
// mergeServiceFiles requires that duplicate strategy is set to include
filesMatching("software/amazon/awssdk/global/handlers/execution.interceptors") {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
}
}
6 changes: 4 additions & 2 deletions javaagent-internal-logging-simple/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ dependencies {

tasks {
val shadowJar by existing(ShadowJar::class) {
// mergeServiceFiles requires that duplicate strategy is set to include
duplicatesStrategy = DuplicatesStrategy.INCLUDE
// required for META-INF/services files relocation
mergeServiceFiles()
// mergeServiceFiles requires that duplicate strategy is set to include
filesMatching("META-INF/services/**") {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}

// Prevents configuration naming conflict with other SLF4J instances
relocate("org.slf4j", "io.opentelemetry.javaagent.slf4j")
Expand Down
25 changes: 23 additions & 2 deletions javaagent/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,15 @@ tasks {

excludeBootstrapClasses()

duplicatesStrategy = DuplicatesStrategy.FAIL
// TODO: remove after updating contrib to 1.50.0
filesMatching("io/opentelemetry/contrib/gcp/resource/version.properties") {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
exclude("META-INF/LICENSE")
exclude("META-INF/NOTICE")
exclude("META-INF/maven/**")

archiveFileName.set("baseJavaagentLibs-relocated-tmp.jar")
}

Expand All @@ -180,6 +189,18 @@ tasks {
// remove MPL licensed content
exclude("okhttp3/internal/publicsuffix/PublicSuffixDatabase.list")

duplicatesStrategy = DuplicatesStrategy.FAIL
// TODO: remove after updating contrib to 1.50.0
filesMatching("io/opentelemetry/contrib/gcp/resource/version.properties") {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
filesMatching("META-INF/io/opentelemetry/instrumentation/**") {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
exclude("META-INF/LICENSE")
exclude("META-INF/NOTICE")
exclude("META-INF/maven/**")

archiveFileName.set("javaagentLibs-relocated-tmp.jar")
}

Expand Down Expand Up @@ -391,8 +412,8 @@ fun CopySpec.isolateClasses(jar: Provider<RegularFile>) {
// important to keep prefix "inst" short, as it is prefixed to lots of strings in runtime mem
into("inst")
rename("(^.*)\\.class\$", "\$1.classdata")
// Rename LICENSE file since it clashes with license dir on non-case sensitive FSs (i.e. Mac)
rename("""^LICENSE$""", "LICENSE.renamed")
exclude("""^LICENSE$""")
exclude("META-INF/LICENSE.txt")
exclude("META-INF/INDEX.LIST")
exclude("META-INF/*.DSA")
exclude("META-INF/*.SF")
Expand Down
6 changes: 4 additions & 2 deletions testing/armeria-shaded-for-testing/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ tasks {
relocate("org.HdrHistogram", "io.opentelemetry.testing.internal.org.hdrhistogram")
relocate("org.LatencyUtils", "io.opentelemetry.testing.internal.org.latencyutils")

// mergeServiceFiles requires that duplicate strategy is set to include
duplicatesStrategy = DuplicatesStrategy.INCLUDE
mergeServiceFiles()
// mergeServiceFiles requires that duplicate strategy is set to include
filesMatching("META-INF/services/**") {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
}

val extractShadowJar by registering(Copy::class) {
Expand Down
6 changes: 4 additions & 2 deletions testing/wiremock-shaded-for-testing/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ tasks {
relocate("javax.servlet", "io.opentelemetry.testing.internal.servlet")
relocate("org.yaml", "io.opentelemetry.testing.internal.yaml")

// mergeServiceFiles requires that duplicate strategy is set to include
duplicatesStrategy = DuplicatesStrategy.INCLUDE
mergeServiceFiles()
// mergeServiceFiles requires that duplicate strategy is set to include
filesMatching("META-INF/services/**") {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
}

val extractShadowJar by registering(Copy::class) {
Expand Down