Skip to content

Commit

Permalink
Fix publishing gradle plugins (#5133)
Browse files Browse the repository at this point in the history
  • Loading branch information
trask authored Jan 15, 2022
1 parent c53d53a commit 5b30f32
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ plugins {
id("com.github.johnrengelman.shadow")
}

// NOTE: any modifications below should also be made in
// io.opentelemetry.instrumentation.muzzle-check.gradle.kts
tasks.withType<ShadowJar>().configureEach {
mergeServiceFiles()
// Merge any AWS SDK service files that may be present (too bad they didn't just use normal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import java.util.stream.StreamSupport
plugins {
`java-library`

id("io.opentelemetry.instrumentation.javaagent-shadowing")
id("com.github.johnrengelman.shadow")
}

// Select a random set of versions to test
Expand Down Expand Up @@ -69,6 +69,42 @@ val shadowMuzzleBootstrap by tasks.registering(ShadowJar::class) {
archiveFileName.set("bootstrap-for-muzzle-check.jar")
}

// 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()
// 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")

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

// Prevents conflict with other SLF4J instances. Important for premain.
relocate("org.slf4j", "io.opentelemetry.javaagent.slf4j")
// rewrite dependencies calling Logger.getLogger
relocate("java.util.logging.Logger", "io.opentelemetry.javaagent.bootstrap.PatchLogger")

// prevents conflict with library instrumentation
relocate("io.opentelemetry.instrumentation", "io.opentelemetry.javaagent.shaded.instrumentation")

// relocate(OpenTelemetry API)
relocate("io.opentelemetry.api", "io.opentelemetry.javaagent.shaded.io.opentelemetry.api")
relocate("io.opentelemetry.semconv", "io.opentelemetry.javaagent.shaded.io.opentelemetry.semconv")
relocate("io.opentelemetry.context", "io.opentelemetry.javaagent.shaded.io.opentelemetry.context")

// relocate(the OpenTelemetry extensions that are used by instrumentation modules)
// these extensions live in the AgentClassLoader, and are injected into the user's class loader
// by the instrumentation modules that use them
relocate("io.opentelemetry.extension.aws", "io.opentelemetry.javaagent.shaded.io.opentelemetry.extension.aws")
relocate("io.opentelemetry.extension.kotlin", "io.opentelemetry.javaagent.shaded.io.opentelemetry.extension.kotlin")

// this is for instrumentation on opentelemetry-api itself
relocate("application.io.opentelemetry", "io.opentelemetry")

// this is for instrumentation on java.util.logging (since java.util.logging itself is shaded above)
relocate("application.java.util.logging", "java.util.logging")
}

val compileMuzzle by tasks.registering {
dependsOn(shadowMuzzleBootstrap)
dependsOn(shadowMuzzleTooling)
Expand Down

0 comments on commit 5b30f32

Please sign in to comment.