java-native-image
java-native-image copied to clipboard
Skip native-image step when using "native build tools maven plugin"
When using this buildpack to build a native image, it will use paketo-buildpacks/native-image buildpack to run native-image
command.
What if I configure the Native Build Tools Maven Plugin in my project, like this, then pass BP_MAVEN_BUILD_ARGUMENTS="-Pnative native:compile"
during build time, I think there is no need to use paketo-buildpacks/native-image
to run native-image
command again. But in the current realization, the native-image
will always be picked up, so I need to pass BP_NATIVE_IMAGE_BUILD_ARGUMENTS
for it.
what is the best practice to build a native image?
Describe the Enhancement
Should support to choose use Native Build Tools Maven Plugin
or use native-image
separately.
Possible Solution
Motivation
Thanks for opening this issue. We have discussed doing this.
Right now, the limitation is that the buildpacks expect the output of the Maven/Gradle build process to be a JAR/WAR. You can override the default and point them to a native-image build, but they still expect the file you're pointing at to be a JAR/WAR file (or if you point to the JAR/WAR from your build, then buildpacks will rebuild your native-image which is wrong).
We would also need a way to set the process types for the native-image binary and do SBOM scanning. Right now, that happens in the native-image buildpack.
For other reads and to help us gauge interest in this, please 👍 if this feature is of interest.
For the time being, the suggest path is to have your Maven/Gradle build produce a JAR/WAR file and enable native-image builds using the paketo-buildpacks/native-image
buildpack. This should work roughly the same, but it runs native-image
directly, instead of from Maven/Gradle.
https://paketo.io/docs/howto/java/#build-an-app-as-a-graalvm-native-image-application
this issue/idea, relates to: https://github.com/paketo-buildpacks/native-image/issues/192