Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply package name shading to native-image config files in grpc-netty-shaded #7540

Closed
dzou opened this issue Oct 20, 2020 · 4 comments · Fixed by #8258
Closed

Apply package name shading to native-image config files in grpc-netty-shaded #7540

dzou opened this issue Oct 20, 2020 · 4 comments · Fixed by #8258

Comments

@dzou
Copy link
Contributor

dzou commented Oct 20, 2020

The grpc-netty-shaded JAR provides several config files under the resources/META-INF dir:

image

I.e. native-image.properties and reflection-config.json in the screenshot.

Inside these config files, the library writers reference Netty package classes, and it would be very useful if these classes could also have their packages renamed during the shading process.

For example META-INF/native-image/io.netty/codec-http/native-image.properties is currently this:

Args = --initialize-at-build-time=io.netty \
       --initialize-at-run-time=io.netty.handler.codec.http.HttpObjectEncoder,io.netty.handler.codec.http.websocketx.WebSocket00FrameEncoder,io.netty.handler.codec.http.websocketx.extensions.compression.DeflateDecoder

But it should be updated to this:

Args = --initialize-at-build-time=io.grpc.netty.shaded.io.netty \
       --initialize-at-run-time=io.grpc.netty.shaded.io.netty.handler.codec.http.HttpObjectEncoder,io.grpc.netty.shaded.io.netty.handler.codec.http.websocketx.WebSocket00FrameEncoder,io.grpc.netty.shaded.io.netty.handler.codec.http.websocketx.extensions.compression.DeflateDecoder

These files and settings are used by Oracle's GraalVM compiler to assist in the ahead-of-time compilation process. The original library writers added it in so that it would work with native image building.

Is your feature request related to a problem?

Yes, this will greatly contribute to the internal effort of getting Google Cloud Java client libraries compatible with GraalVM native image compilation.

There is significant user interest from Native image app developers for this feature (Quarkus, Micronaut, Spring + GraalVM).

Describe the solution you'd like

Is it possible to extend the shading process to apply package name updates to config files under META-INF/native-image/?

Describe alternatives you've considered

Users can duplicate configuration on their own manually, but this runs the risk of going out of sync with the Netty repo when changes are made.

cc/ @meltsufin

@sanjaypujare
Copy link
Contributor

cc @ejona86

@ejona86
Copy link
Member

ejona86 commented Oct 27, 2020

It appears https://www.graalvm.org/reference-manual/native-image/BuildConfiguration/ is the documentation for this format.

It seems this will need a custom Transformer, potentially along with a Relocator to rework the folder structure. https://imperceptiblethoughts.com/shadow/configuration/merging/ . Ideally that code would be in the Shadow plugin so it can be reused by others.

@dzou
Copy link
Contributor Author

dzou commented Jun 3, 2021

It appears https://www.graalvm.org/reference-manual/native-image/BuildConfiguration/ is the documentation for this format.

It seems this will need a custom Transformer, potentially along with a Relocator to rework the folder structure. https://imperceptiblethoughts.com/shadow/configuration/merging/ . Ideally that code would be in the Shadow plugin so it can be reused by others.

Hey, I would like to contribute to this. Could you provide some more guidance on where the Transformer code would live, and how try testing out the shading logic?

@ejona86
Copy link
Member

ejona86 commented Jun 3, 2021

Initially the transformer code would probably live in https://github.com/grpc/grpc-java/blob/master/netty/shaded/build.gradle , but we should consider upstreaming it.

Here's the documentation for the shadow plugin: https://imperceptiblethoughts.com/shadow/configuration/merging/

@ejona86 ejona86 modified the milestones: Next, 1.39 Jun 24, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants