Reputation: 43
I already got add the resource to the classpath using
<additionalBuildArg>-H:IncludeResources=.*/kubernetes_auth.crt$</additionalBuildArg>
<additionalBuildArg>-H:Log=registerResource:verbose</additionalBuildArg>
When I build the image I can see in the log that if I add it
ResourcesFeature: registerResource: classes/kubernetes_auth.crt
But when I try to read the resource with the following code that works in Java, it returns null
InputStream is = KubernetesResource.class.getResourceAsStream("/kubernetes_auth.crt");
I have tried with these variants but same returns null
Thread.currentThread().getContextClassLoader().getResourceAsStream("/kubernetes_auth.crt");
ClassLoader.getSystemClassLoader().getResourceAsStream("/kubernetes_auth.crt");
getClass().getResourceAsStream("classes/kubernetes_auth.crt");
Versions of quuarkus 0.13.3 and 0.14.0 and Graal rc14, rc15, rc16
Upvotes: 3
Views: 4642
Reputation: 1280
As you discovered, you need to specify the resource to be loaded.
As of Quarkus 1.8.0 (and for some time before), you can list resources that should be available for the native image to load using a property:
quarkus.native.resources.includes=kubernetes_auth.crt
The property supports a comma-separated list of files. The syntax for this list is described in the configuration reference for building native images: https://quarkus.io/guides/building-native-image#configuration-reference
Upvotes: 3