Created
July 29, 2024 08:19
-
-
Save Krever/4f33be8e1ce27e8a7001b26bf160c174 to your computer and use it in GitHub Desktop.
picocli grpc CLI in scala build with native-image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
scala-cli \ | |
--power \ | |
package \ | |
--native-image \ | |
--graalvm-java-version 21 \ | |
--graalvm-version 21.0.2 \ | |
./main \ | |
-o sbadmin2 \ | |
--force \ | |
--main-class sbadmin2.Main \ | |
-- \ | |
-H:ReflectionConfigurationFiles=picocli-reflect.json,io.grpc-grpc-netty-reflect-config.json,io.netty-netty-common-reflect-config.json \ | |
--initialize-at-run-time=io.grpc.netty.shaded.io.netty \ | |
--initialize-at-build-time=ch.qos.logback \ | |
--initialize-at-build-time=org.slf4j |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Generates json file with config of reflective accesses required by picocli | |
# uses utils provided by picocli: https://picocli.info/picocli-on-graalvm.html | |
scala-cli run \ | |
--dep info.picocli:picocli-codegen:4.7.6 \ | |
./main \ | |
--main-class picocli.codegen.aot.graalvm.ReflectionConfigGenerator \ | |
-- \ | |
sbadmin2.commands.MainCmd \ | |
sbadmin2.commands.utils.EchoCmd \ | |
> picocli-reflect.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# those files are required because grpc-java have a shaded netty with broken native-image config. | |
# We need to take native netty config available here: https://github.com/oracle/graalvm-reachability-metadata/tree/master/metadata/io.netty | |
# and adjust packages for grpc-shaded ones. | |
curl \ | |
https://raw.githubusercontent.com/oracle/graalvm-reachability-metadata/master/metadata/io.grpc/grpc-netty/1.51.0/reflect-config.json \ | |
| sed -e 's/"io.grpc.netty\./"io.grpc.netty.shaded.io.grpc.netty./g' \ | |
| sed -e 's/"io\.netty\./"io.grpc.netty.shaded.io.netty./g' \ | |
> io.grpc-grpc-netty-reflect-config.json | |
curl \ | |
https://raw.githubusercontent.com/oracle/graalvm-reachability-metadata/master/metadata/io.netty/netty-common/4.1.80.Final/reflect-config.json \ | |
| sed -e 's/"io\.netty\./"io.grpc.netty.shaded.io.netty./g' \ | |
> io.netty-netty-common-reflect-config.json | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment