paketo-buildpacks / native-image

A Cloud Native Buildpack that creates native images from Java applications
Apache License 2.0
46 stars 9 forks source link

Support append BP_NATIVE_IMAGE_BUILD_ARGUMENTS to the end of command #288

Open czp3009 opened 10 months ago

czp3009 commented 10 months ago

Describe the Enhancement

After using BP_NATIVE_IMAGE_BUILD_ARGUMENTS, these arguments are always added to the very beginning of the command(before -cp), example:

[creator]         Executing native-image --no-fallback -H:+StaticExecutableWithDynamicLibC @/workspace/META-INF/native-image/argfile $BP_NATIVE_IMAGE_BUILD_ARGUMENTS -H:Name=/layers/paketo-buildpacks_native-image/native-image/xxxx -cp xxxx

Is it possible to append BP_NATIVE_IMAGE_BUILD_ARGUMENTS to the end of the command instead of the beginning? example:

native-image --no-fallback -H:+StaticExecutableWithDynamicLibC @/workspace/META-INF/native-image/argfile -H:Name=/layers/paketo-buildpacks_native-image/native-image/xxxx -cp xxxx $BP_NATIVE_IMAGE_BUILD_ARGUMENTS

Possible Solution

Add another environment variable to switch this feature on and off

Motivation

In some cases, it is necessary to override graalvm native image arguments that are included in some of the dependency jars. additional command line arguments must be placed at the end of the line for this to work (actually, after -cp)

example: https://github.com/apache/camel-quarkus/issues/5006#issuecomment-1611504444

In order to override RunReachabilityHandlersConcurrently in google-gax, this parameter must be placed last

dmikusa commented 10 months ago

This sounds plausible. The way the command is built up, it may not be as easy as it sounds to guarantee though. We can look at possible solutions.

I'll mark this as a feature request.