Oracle GraalVM Now Available as a Paketo Buildpack

Fabio Niephaus
graalvm
Published in
3 min readDec 12, 2023

--

Today, we are excited to share that Oracle GraalVM is now available as a Paketo buildpack! Together with the Paketo team, we have integrated Oracle GraalVM into the Oracle buildpack. This means that all you have to do is add both the Native Image and Oracle buildpacks to your buildpack configuration and you are good to go!

Earlier this year, we introduced Oracle GraalVM that provides many advanced features available for free, both for development and production. It is great to see that there is an increasing interest in the community to use this new GraalVM distribution, not only to build smaller and faster native images but also to generate SBOMs and use other advanced features such as G1 GC or PGO. Oracle GraalVM is already available through SDKMAN!, GitHub Action for GraalVM, the Script Friendly URLs, and the Homebrew Tap for GraalVM. Buildpack support was highly requested and has finally landed!

How to build Spring Boot Applications with Oracle GraalVM?

Spring Boot 3.0 introduced first-class support for generating native images with GraalVM. For this, applications built with Spring Boot 3+ can leverage the Native Image buildpack to create native images. To instruct the build process to use Oracle GraalVM, all you have to do is tweak your Maven or Gradle configuration.

For Maven, make sure the following four bold lines are in the configuration of the spring-boot-maven-plugin in your pom.xml :

<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<image>
<!-- ... -->
<buildpacks>
<buildpack>docker.io/paketobuildpacks/oracle</buildpack>
<buildpack>urn:cnb:builder:paketo-buildpacks/java-native-image</buildpack>
</buildpacks>

</image>
</configuration>
</plugin>

If you are using Gradle — Groovy, add the following lines to your build.gradle :

bootBuildImage {
buildpacks = ["docker.io/paketobuildpacks/oracle", "urn:cnb:builder:paketo-buildpacks/java-native-image"]
}

And for Gradle — Kotlin, you just need to add these lines to your build.gradle.kts:

tasks.getByName<BootBuildImage>("bootBuildImage") {
buildpacks = listOf("docker.io/paketobuildpacks/oracle", "urn:cnb:builder:paketo-buildpacks/java-native-image")
}

When you then either run ./mvnw -Pnative spring-boot:build-image for Maven or ./gradlew bootBuildImage for Gradle, your application will be built with Oracle GraalVM. You can verify this by going through the build log. “Oracle GraalVM” should be part of the vendor version:

...
[creator] =================================================================
[creator] GraalVM Native Image: Generating 'MyApplication' (executable)...
[creator] =================================================================
[creator] For detailed information and explanations on the build output, visit:
[creator] https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/BuildOutput.md
[creator] -----------------------------------------------------------------
[creator] [1/8] Initializing... (4.1s @ 0.18GB)
[creator] Java version: 21.0.1+12, vendor version: Oracle GraalVM 21.0.1+12.1
...

Of course, building Spring Boot applications with Oracle GraalVM is not the only thing you can do with the updated Oracle buildpack. The Paketo documentation provides several examples that show you how to build applications with GraalVM Native Image using buildpacks. And in case you are interested in building containers that run your Java application on Oracle GraalVM with the Graal JIT, it is already on the roadmap.

Wrapping Up

We hope you are just as excited as we are that Oracle GraalVM is now available as a buildpack! This wouldn’t have been possible without the help of the Paketo team. So, a big thank you to them!

For more details, take a look at the announcement on the Paketo blog. And for anyone interested, you can find the RFC with additional information here. The implementation of the integration is in this pull request.

Also, we always welcome user feedback, so please share any suggestions or ideas with us on Slack, GitHub, or X/Twitter.

Happy building with Oracle GraalVM! 🚀

— the GraalVM team

--

--

Fabio Niephaus
graalvm

Researcher on the GraalVM team at Oracle Labs. Developer tools, languages, virtual machines. HPI PhD graduate. Previously at Google and Maton Guitars.