GradleUp / shadow

Gradle plugin to create fat/uber JARs, apply file transforms, and relocate packages for applications and libraries. Gradle version of Maven's Shade plugin.
https://www.gradleup.com/shadow/
Apache License 2.0
3.69k stars 389 forks source link

NettyChannelBuilder can't locate the name resolver provider from service files when build with minimize shadowJar #926

Open ee07b415 opened 1 month ago

ee07b415 commented 1 month ago

Please check the User Guide before submitting "how do I do 'x'?" questions!

Shadow Version

7.1.2

Gradle Version

7.6.4

Expected Behavior

The grpc managed channel can start connection without any problem.

Actual Behavior

After add the minimize () to the shadowJar task, the execution start to saw error like: io.grpc.NameResolverProvider: io.grpc.netty.UdsNameResolverProvider not a subtype

When I unzip the jar file I can find the io.grpc.NameResolveProvider file and the content: io.grpc.netty.UdsNameResolverProvider io.grpc.internal.DnsNameResolverProvider io.grpc.googleapis.GoogleCloudToProdExperimentalNameResolverProvider io.grpc.googleapis.GoogleCloudToProdNameResolverProvider io.grpc.grpclb.SecretGrpclbNameResolverProvider$Provider io.grpc.netty.shaded.io.grpc.netty.UdsNameResolverProvider

So I think after enable the minimize, the class in jar file can't read from the metadata-INF files for the class it needed, so I'm not sure how to config the minize to include resource file

Gradle Build Script(s)

configurations { val flinkShadowJar = create("flinkShadowJar") flinkShadowJar.apply { extendsFrom(configurations.runtimeClasspath.get()) } }

tasks.shadowJar { archiveBaseName.set("flink-job") archiveVersion.set("1.0-SNAPSHOT") archiveClassifier.set("") minimize () mergeServiceFiles () isZip64 = true configurations = listOf(project.configurations.getByName("flinkShadowJar")) }

Content of Shadow JAR (jar tf <jar file> - post link to GIST if too long)