Skip to content

Commit abad390

Browse files
fix: resolve gRPC NameResolver service file merging in shaded JAR (#122)
- Fix IllegalArgumentException: Address types of NameResolver 'unix' not supported - Root cause: Shadow plugin's duplicatesStrategy=EXCLUDE prevented merging of service files from multiple JARs (grpc-core and grpc-netty) - Solution: Set duplicatesStrategy=INCLUDE globally, EXCLUDE for non-service files - Ensures both DnsNameResolverProvider and UdsNameResolverProvider are included - Resolves URI scheme resolution from unix:// back to proper dns:// Fixes version 0.35.0 regression where shaded JAR was missing critical gRPC providers
1 parent 6dd1615 commit abad390

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

buildSrc/src/main/kotlin/shading.gradle.kts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,12 @@ abstract class ShadingExtension @Inject constructor(
5252

5353
isReproducibleFileOrder = true
5454
isPreserveFileTimestamps = false
55-
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
55+
duplicatesStrategy = DuplicatesStrategy.INCLUDE
56+
57+
// Exclude duplicates for non-service files to avoid bloat
58+
filesNotMatching("META-INF/services/**") {
59+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
60+
}
5661

5762
// JAR naming configuration
5863
archiveBaseName.set(project.name)
@@ -74,6 +79,8 @@ abstract class ShadingExtension @Inject constructor(
7479
relocate("org.apache.commons", "$shadeBase.org.apache.commons")
7580
relocate("org.apache.hc", "$shadeBase.org.apache.hc")
7681

82+
// Use built-in service file merging with package relocation support
83+
// This automatically handles relocated class names in service files!
7784
mergeServiceFiles {
7885
exclude("META-INF/services/java.sql.Driver")
7986
}

0 commit comments

Comments
 (0)