Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include classpath resources in a Quarkus native image?

Tags:

quarkus

It seems that by default the native image generated by Quarkus does not include any classpath resources corresponding to stuff from src/main/resources/.

From the GraalVM docs, I sort of understand why this happens, but now I'm stuck. Is there a way to configure the quarkus-maven-plugin to include the resources in the native image?

like image 538
Harald Wellmann Avatar asked Mar 22 '19 13:03

Harald Wellmann


People also ask

What is native in Quarkus?

Kubernetes-native Quarkus allows developers to automatically generate Kubernetes resources including building and deploying container images without having to manually create YAML files.

Does Quarkus use reflection?

Quarkus makes registration of reflection in an extension a breeze by using ReflectiveClassBuildItem , thus eliminating the need for a JSON configuration file. More information about reflection in GraalVM can be found here.

How do I run a native image?

For compilation native-image depends on the local toolchain. Install glibc-devel , zlib-devel (header files for the C library and zlib ) and gcc , using a package manager available on your OS. Some Linux distributions may additionally require libstdc++-static .

Does Quarkus require GraalVM?

Quarkus needs GraalVM installation for building the native executables.


1 Answers

We have a layer to do that programmatically in extensions but, right now, we don't have any user facing API for applications.

So for the time being, you could use this option of the quarkus-maven-plugin:

 <quarkus.native.additional-build-args>-H:ResourceConfigurationFiles=resources-config.json</quarkus.native.additional-build-args>

Or you can also define it in your application.properties:

quarkus.native.additional-build-args =-H:ResourceConfigurationFiles=resources-config.json

Everything is documented here: https://quarkus.io/guides/writing-native-applications-tips .

like image 143
Guillaume Smet Avatar answered Sep 25 '22 15:09

Guillaume Smet