Converting your CLI to a native application

It is also possible to compile your Agent SDK application to a native executable. To get started, you will need to ensure that you have GraalVM installed and configured by downloading the GraalVM at https://www.graalvm.org/downloads/. GraalVM 24 is the preferred version.

Once you have GraalVM installed, you need to update your build.xml for your project to mirror the following:

plugins {
    id 'java'
    id "io.freefair.lombok" version "8.6"
    id("org.springframework.boot") version "3.5.3"
    id 'org.graalvm.buildtools.native' version '0.10.6'
}

You may also want to disable most logging in this mode. You can do that by adding the following to application.properties:

logging.level.root = OFF

Now, you just need to tell Gradle to build the native image.

Remember, you need to set GraalVM as your default Java VM first - this includes setting the JAVA_HOME environment variable!

./gradlew nativeCompile

You'll see some output as it compiles that looks like the following:

========================================================================================================================
GraalVM Native Image: Generating 'agent-sdk-sample' (executable)...
========================================================================================================================
For detailed information and explanations on the build output, visit:
https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/BuildOutput.md
------------------------------------------------------------------------------------------------------------------------

After a bit, you'll see it successfully complete and you'll have a native executable! Now we can run:

./build/native/nativeCompile/agent-sdk-sample
matt@Matthews-MBP-3 nativeCompile % ./agent-sdk-sample

______                _      _             _
| ___ \              | |    | |           (_)
| |_/ /__  ___  _ __ | | ___| | ___   __ _ _  ___
|  __/ _ \/ _ \| '_ \| |/ _ \ |/ _ \ / _` | |/ __|
| | |  __/ (_) | |_) | |  __/ | (_) | (_| | | (__
\_|  \___|\___/| .__/|_|\___|_|\___/ \__, |_|\___|
               | |                    __/ |
               |_|                   |___/

 :: Spring Boot ::                (v3.5.3)
 :: Peoplelogic Agent SDK ::   (v1.0.7.35)

That's it!

Last updated

Was this helpful?