Rework service file merging (#14617)
This commit is contained in:
parent
7519b26ee0
commit
f1da1f0861
|
|
@ -7,12 +7,18 @@ plugins {
|
||||||
// NOTE: any modifications below should also be made in
|
// NOTE: any modifications below should also be made in
|
||||||
// io.opentelemetry.instrumentation.muzzle-check.gradle.kts
|
// io.opentelemetry.instrumentation.muzzle-check.gradle.kts
|
||||||
tasks.withType<ShadowJar>().configureEach {
|
tasks.withType<ShadowJar>().configureEach {
|
||||||
// mergeServiceFiles requires that duplicate strategy is set to include
|
|
||||||
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
|
||||||
mergeServiceFiles()
|
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
|
// Merge any AWS SDK service files that may be present (too bad they didn't just use normal
|
||||||
// service loader...)
|
// service loader...)
|
||||||
mergeServiceFiles("software/amazon/awssdk/global/handlers")
|
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")
|
exclude("**/module-info.class")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,7 @@ CopySpec isolateClasses(Iterable<File> jars) {
|
||||||
from(zipTree(it)) {
|
from(zipTree(it)) {
|
||||||
into("inst")
|
into("inst")
|
||||||
rename("^(.*)\\.class\$", "\$1.classdata")
|
rename("^(.*)\\.class\$", "\$1.classdata")
|
||||||
// Rename LICENSE file since it clashes with license dir on non-case sensitive FSs (i.e. Mac)
|
exclude("^LICENSE\$")
|
||||||
rename("^LICENSE\$", "LICENSE.renamed")
|
|
||||||
exclude("META-INF/INDEX.LIST")
|
exclude("META-INF/INDEX.LIST")
|
||||||
exclude("META-INF/*.DSA")
|
exclude("META-INF/*.DSA")
|
||||||
exclude("META-INF/*.SF")
|
exclude("META-INF/*.SF")
|
||||||
|
|
@ -66,9 +65,12 @@ tasks {
|
||||||
|
|
||||||
archiveFileName.set("javaagentLibs-relocated.jar")
|
archiveFileName.set("javaagentLibs-relocated.jar")
|
||||||
|
|
||||||
// mergeServiceFiles requires that duplicate strategy is set to include
|
duplicatesStrategy = DuplicatesStrategy.FAIL
|
||||||
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
|
||||||
mergeServiceFiles()
|
mergeServiceFiles()
|
||||||
|
// mergeServiceFiles requires that duplicate strategy is set to include
|
||||||
|
filesMatching("META-INF/services/**") {
|
||||||
|
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
||||||
|
}
|
||||||
exclude("**/module-info.class")
|
exclude("**/module-info.class")
|
||||||
relocatePackages(it)
|
relocatePackages(it)
|
||||||
|
|
||||||
|
|
@ -105,9 +107,12 @@ tasks {
|
||||||
|
|
||||||
archiveClassifier.set("all")
|
archiveClassifier.set("all")
|
||||||
|
|
||||||
// mergeServiceFiles requires that duplicate strategy is set to include
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||||
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
|
||||||
mergeServiceFiles("inst/META-INF/services")
|
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")
|
exclude("**/module-info.class")
|
||||||
relocatePackages(it)
|
relocatePackages(it)
|
||||||
|
|
|
||||||
|
|
@ -36,9 +36,11 @@ dependencies {
|
||||||
shadowJar {
|
shadowJar {
|
||||||
configurations = [project.configurations.runtimeClasspath, project.configurations.testInstrumentation]
|
configurations = [project.configurations.runtimeClasspath, project.configurations.testInstrumentation]
|
||||||
|
|
||||||
// mergeServiceFiles requires that duplicate strategy is set to include
|
|
||||||
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
|
||||||
mergeServiceFiles()
|
mergeServiceFiles()
|
||||||
|
// mergeServiceFiles requires that duplicate strategy is set to include
|
||||||
|
filesMatching("inst/META-INF/services/**") {
|
||||||
|
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
||||||
|
}
|
||||||
|
|
||||||
archiveFileName = 'agent-testing.jar'
|
archiveFileName = 'agent-testing.jar'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -61,9 +61,13 @@ tasks {
|
||||||
|
|
||||||
archiveFileName.set("javaagentLibs-relocated.jar")
|
archiveFileName.set("javaagentLibs-relocated.jar")
|
||||||
|
|
||||||
// mergeServiceFiles requires that duplicate strategy is set to include
|
duplicatesStrategy = DuplicatesStrategy.FAIL
|
||||||
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
|
||||||
mergeServiceFiles()
|
mergeServiceFiles()
|
||||||
|
// mergeServiceFiles requires that duplicate strategy is set to include
|
||||||
|
filesMatching("META-INF/services/**") {
|
||||||
|
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
||||||
|
}
|
||||||
|
|
||||||
exclude("**/module-info.class")
|
exclude("**/module-info.class")
|
||||||
relocatePackages(it)
|
relocatePackages(it)
|
||||||
|
|
||||||
|
|
@ -100,9 +104,12 @@ tasks {
|
||||||
|
|
||||||
archiveClassifier.set("")
|
archiveClassifier.set("")
|
||||||
|
|
||||||
// mergeServiceFiles requires that duplicate strategy is set to include
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||||
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
|
||||||
mergeServiceFiles("inst/META-INF/services")
|
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")
|
exclude("**/module-info.class")
|
||||||
relocatePackages(it)
|
relocatePackages(it)
|
||||||
|
|
|
||||||
|
|
@ -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
|
// this is a copied from io.opentelemetry.instrumentation.javaagent-shadowing for now at least to
|
||||||
// avoid publishing io.opentelemetry.instrumentation.javaagent-shadowing publicly
|
// avoid publishing io.opentelemetry.instrumentation.javaagent-shadowing publicly
|
||||||
tasks.withType<ShadowJar>().configureEach {
|
tasks.withType<ShadowJar>().configureEach {
|
||||||
// mergeServiceFiles requires that duplicate strategy is set to include
|
|
||||||
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
|
||||||
mergeServiceFiles()
|
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
|
// Merge any AWS SDK service files that may be present (too bad they didn't just use normal
|
||||||
// service loader...)
|
// service loader...)
|
||||||
mergeServiceFiles("software/amazon/awssdk/global/handlers")
|
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")
|
exclude("**/module-info.class")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("otel.javaagent-instrumentation")
|
id("otel.javaagent-instrumentation")
|
||||||
}
|
}
|
||||||
|
|
@ -226,11 +228,13 @@ tasks {
|
||||||
systemProperty("collectMetadata", collectMetadata)
|
systemProperty("collectMetadata", collectMetadata)
|
||||||
}
|
}
|
||||||
|
|
||||||
withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>().configureEach {
|
withType<ShadowJar>().configureEach {
|
||||||
// mergeServiceFiles requires that duplicate strategy is set to include
|
|
||||||
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
|
||||||
mergeServiceFiles {
|
mergeServiceFiles {
|
||||||
include("software/amazon/awssdk/global/handlers/execution.interceptors")
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,12 @@ dependencies {
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
val shadowJar by existing(ShadowJar::class) {
|
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
|
// required for META-INF/services files relocation
|
||||||
mergeServiceFiles()
|
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
|
// Prevents configuration naming conflict with other SLF4J instances
|
||||||
relocate("org.slf4j", "io.opentelemetry.javaagent.slf4j")
|
relocate("org.slf4j", "io.opentelemetry.javaagent.slf4j")
|
||||||
|
|
|
||||||
|
|
@ -160,6 +160,15 @@ tasks {
|
||||||
|
|
||||||
excludeBootstrapClasses()
|
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")
|
archiveFileName.set("baseJavaagentLibs-relocated-tmp.jar")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -180,6 +189,18 @@ tasks {
|
||||||
// remove MPL licensed content
|
// remove MPL licensed content
|
||||||
exclude("okhttp3/internal/publicsuffix/PublicSuffixDatabase.list")
|
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")
|
archiveFileName.set("javaagentLibs-relocated-tmp.jar")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -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
|
// important to keep prefix "inst" short, as it is prefixed to lots of strings in runtime mem
|
||||||
into("inst")
|
into("inst")
|
||||||
rename("(^.*)\\.class\$", "\$1.classdata")
|
rename("(^.*)\\.class\$", "\$1.classdata")
|
||||||
// Rename LICENSE file since it clashes with license dir on non-case sensitive FSs (i.e. Mac)
|
exclude("""^LICENSE$""")
|
||||||
rename("""^LICENSE$""", "LICENSE.renamed")
|
exclude("META-INF/LICENSE.txt")
|
||||||
exclude("META-INF/INDEX.LIST")
|
exclude("META-INF/INDEX.LIST")
|
||||||
exclude("META-INF/*.DSA")
|
exclude("META-INF/*.DSA")
|
||||||
exclude("META-INF/*.SF")
|
exclude("META-INF/*.SF")
|
||||||
|
|
|
||||||
|
|
@ -37,9 +37,11 @@ tasks {
|
||||||
relocate("org.HdrHistogram", "io.opentelemetry.testing.internal.org.hdrhistogram")
|
relocate("org.HdrHistogram", "io.opentelemetry.testing.internal.org.hdrhistogram")
|
||||||
relocate("org.LatencyUtils", "io.opentelemetry.testing.internal.org.latencyutils")
|
relocate("org.LatencyUtils", "io.opentelemetry.testing.internal.org.latencyutils")
|
||||||
|
|
||||||
// mergeServiceFiles requires that duplicate strategy is set to include
|
|
||||||
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
|
||||||
mergeServiceFiles()
|
mergeServiceFiles()
|
||||||
|
// mergeServiceFiles requires that duplicate strategy is set to include
|
||||||
|
filesMatching("META-INF/services/**") {
|
||||||
|
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val extractShadowJar by registering(Copy::class) {
|
val extractShadowJar by registering(Copy::class) {
|
||||||
|
|
|
||||||
|
|
@ -35,9 +35,11 @@ tasks {
|
||||||
relocate("javax.servlet", "io.opentelemetry.testing.internal.servlet")
|
relocate("javax.servlet", "io.opentelemetry.testing.internal.servlet")
|
||||||
relocate("org.yaml", "io.opentelemetry.testing.internal.yaml")
|
relocate("org.yaml", "io.opentelemetry.testing.internal.yaml")
|
||||||
|
|
||||||
// mergeServiceFiles requires that duplicate strategy is set to include
|
|
||||||
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
|
||||||
mergeServiceFiles()
|
mergeServiceFiles()
|
||||||
|
// mergeServiceFiles requires that duplicate strategy is set to include
|
||||||
|
filesMatching("META-INF/services/**") {
|
||||||
|
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val extractShadowJar by registering(Copy::class) {
|
val extractShadowJar by registering(Copy::class) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue