You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ pack build --builder paketobuildpacks/builder:tiny --env BP_NATIVE_IMAGE=true public-static-main:gradle
...
Downloading from https://download.bell-sw.com/vm/22.0.0.2/bellsoft-liberica-vm-core-openjdk11-22.0.0.2-linux-amd64.tar.gz
...
Downloading https://services.gradle.org/distributions/gradle-7.4.1-bin.zip
...
Daemon will be stopped at the end of the build
> Task :compileJava
> Task :processResources NO-SOURCE
> Task :classes
> Task :jar
> Task :assemble
BUILD SUCCESSFUL in 36s
2 actionable tasks: 2 executed
...
Paketo Native Image Buildpack 5.2.0
https://github.com/paketo-buildpacks/native-image
Build Configuration:
$BP_BINARY_COMPRESSION_METHOD Compression mechanism used to reduce binary size. Options: `none` (default), `upx` or `gzexe`
$BP_NATIVE_IMAGE true enable native image build
$BP_NATIVE_IMAGE_BUILD_ARGUMENTS arguments to pass to the native-image command
$BP_NATIVE_IMAGE_BUILD_ARGUMENTS_FILE a file with arguments to pass to the native-image command
$BP_NATIVE_IMAGE_BUILT_ARTIFACT the built application artifact explicitly, required if building from a JAR
Native Image: Contributing to layer
GraalVM 22.0.0.2 Java 11 CE (Java Version 11.0.14.1+1-LTS)
Executing native-image -H:+StaticExecutableWithDynamicLibC -jar /workspace
Error: /workspace is a directory. (-jar requires a valid jarfile)
unable to invoke layer creator
unable to contribute native-image layer
error running build
exit status 1
ERROR: failed to build: exit status 1
ERROR: failed to build: executing lifecycle: failed with status code: 51
There's too much magic going on, and I have absolutely no idea whether I'm doing something wrong, or whether what I'm trying to do is unsupported.
Can you provide a working example for native-image + gradle?
The text was updated successfully, but these errors were encountered:
lestephane
changed the title
Unable to derive a java-native-image gradle project from the maven sample
Unable to derive a java-native-image gradle project from the public-static-main maven sample
Mar 18, 2022
lestephane
changed the title
Unable to derive a java-native-image gradle project from the public-static-main maven sample
Unable to derive a gradle based version of the public-static-main native-image maven sample
Mar 18, 2022
@lestephane - Can you include the full output of your build? The error is because something is missing from the output (it seems like it can't find a JAR file) of running the Gradle build. I can't see that output though, so I'm not totally sure what's happened.
Also, you may want to try with this setting and see if that helps: https://github.com/paketo-buildpacks/samples/blob/main/java/gradle/build.gradle#L11-L13 We use that with the Boot demos because they produce two JAR files, the Boot executable JAR and a regular JAR. This suppresses the regular JAR. Not sure if your app is a Boot app or not, but maybe worth a try.
Maybe also helpful for us to understand. What do you get when you gradle assemble locally? With the Maven version, when you mvn package you get an output executable JAR. The example works because there is an executable JAR produced.
Buildpacks are just a pipeline of actions which get performed, so the output of Gradle running gets fed into the input of the next step which is native image running. The native image command is expecting a JAR, but not finding one which is why it fails. Verifying that gradle assemble produces an executable JAR would help to verify the input to native image. Thanks.
I started from the public-static-main sample, removed the maven project file, and used instead:
build.gradle.kts
gradle-wrapper.properties
Pack command + Output
There's too much magic going on, and I have absolutely no idea whether I'm doing something wrong, or whether what I'm trying to do is unsupported.
Can you provide a working example for native-image + gradle?
The text was updated successfully, but these errors were encountered: