diff --git a/HELP.md b/HELP.md index 77eddac..d1c10e8 100644 --- a/HELP.md +++ b/HELP.md @@ -6,9 +6,58 @@ For further reference, please consider the following sections: * [Official Gradle documentation](https://docs.gradle.org) * [Spring Boot Gradle Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/3.2.4/gradle-plugin/reference/html/) * [Create an OCI image](https://docs.spring.io/spring-boot/docs/3.2.4/gradle-plugin/reference/html/#build-image) +* [GraalVM Native Image Support](https://docs.spring.io/spring-boot/docs/3.2.4/reference/html/native-image.html#native-image) ### Additional Links These additional references should also help you: * [Gradle Build Scans – insights for your project's build](https://scans.gradle.com#gradle) +* [Configure AOT settings in Build Plugin](https://docs.spring.io/spring-boot/docs/3.2.4/gradle-plugin/reference/htmlsingle/#aot) + +## GraalVM Native Support + +This project has been configured to let you generate either a lightweight container or a native executable. +It is also possible to run your tests in a native image. + +### Lightweight Container with Cloud Native Buildpacks +If you're already familiar with Spring Boot container images support, this is the easiest way to get started. +Docker should be installed and configured on your machine prior to creating the image. + +To create the image, run the following goal: + +``` +$ ./gradlew bootBuildImage +``` + +Then, you can run the app like any other container: + +``` +$ docker run --rm omnibus:0.0.1-SNAPSHOT +``` + +### Executable with Native Build Tools +Use this option if you want to explore more options such as running your tests in a native image. +The GraalVM `native-image` compiler should be installed and configured on your machine. + +NOTE: GraalVM 22.3+ is required. + +To create the executable, run the following goal: + +``` +$ ./gradlew nativeCompile +``` + +Then, you can run the app as follows: +``` +$ build/native/nativeCompile/omnibus +``` + +You can also run your existing tests suite in a native image. +This is an efficient way to validate the compatibility of your application. + +To run your existing tests in a native image, run the following goal: + +``` +$ ./gradlew nativeTest +``` diff --git a/build.gradle.kts b/build.gradle.kts index 3ff340c..f5e2bf6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,6 +3,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { id("org.springframework.boot") version "3.2.4" id("io.spring.dependency-management") version "1.1.4" + id("org.graalvm.buildtools.native") version "0.9.28" kotlin("jvm") version "1.9.23" kotlin("plugin.spring") version "1.9.23" }