sbt / sbt-native-packager

sbt Native Packager
https://sbt-native-packager.readthedocs.io/en/stable/
BSD 2-Clause "Simplified" License
1.59k stars 437 forks source link

GraalVMNativeImagePlugin ignores resources in src/graal #1542

Closed heaven-born closed 1 year ago

heaven-born commented 1 year ago

Expected behaviour

I expect that files located in src/graal will be included in the native-image classpath and packaged into the image as resources taking into account that I reference using -H:IncludeResources to my resource.

Actual behaviour

The files become available under /opt/graalvm/stage/resources in a docker container, but they are not included in the classpath and not included in the binary image.

Information

This is the configuration:

.enablePlugins(GraalVMNativeImagePlugin)
.settings(
 ...
    GraalVMNativeImage / mainClass := Some("info.mshaper.EntryPoint"),
    GraalVMNativeImage / containerBuildImage := GraalVMNativeImagePlugin.generateContainerBuildImage( "aws_lnx2_graalvm") .value
graalVMNativeImageOptions := Seq(... , -H:IncludeResources=seed.conf , ...)
...
)

sbt-native-packager plugin version 1.9.16 GraalVM 22.3.1 Java 19 CE (Java Version 19.0.2+7-jvmci-22.3-b12)

I couldn't get how to log command that is being executed from sbt, so I used another bug in the plugin in order to print the error message that includes the CMD (The bug: the plugin ignores graalVMNativeImageCommand). The -cp in the command line doesn't include /opt/graalvm/stage/resources directory, so the resources are not included in the image.