leviysoft / mockingbird

Flexible mock server
Apache License 2.0
13 stars 3 forks source link

How to build native-image #76

Closed hAh0L13 closed 2 months ago

hAh0L13 commented 2 months ago

Version: main

Expected behavior

Documented, easy-to-reproduce way to build own native-image for mockingbird

Actual behavior

No docs. Try to use GraalVM JDK-22 directly and try to use native-image sbt plugin v0.3.4 Direct use of native-image binary isn't possible - which Class should I use? Or which jar should I use and so. Using plugin resolve this problems, but produce errors -

Caused by: java.lang.IllegalStateException: Polyglot version compatibility check failed.
Your Java runtime '22.0.2+9-jvmci-b01' with native-image feature version '24.0.2' is incompatible with polyglot version '23.1.4'.
Update the org.graalvm.polyglot versions to at least '24.0.2' to resolve this.

When I bumped Polyglot version or ignore this error, another error occurs:

Caused by: java.lang.IllegalAccessError: superinterface check failed: class com.oracle.truffle.runtime.enterprise.EnterpriseTruffleTypes (in unnamed module @0x1af05b03) cannot access class com.oracle.truffle.runtime.TruffleTypes (in module org.graalvm.truffle.runtime) because module org.graalvm.truffle.runtime does not export com.oracle.truffle.runtime to unnamed module @0x1af05b03

Can you provide some docs about building native-image?

@mockingbird/maintainers

danslapman commented 2 months ago

Hi @hAh0L13!

I didn't tried GraalVM JDK-22 yet, mockingbird is currently built on JDK-21. As for the question - there's a guide for building mockingbird on a local machine, here it is: https://github.com/leviysoft/mockingbird/wiki/Local-backend-development#running-mockinbird-as-a-native-image

Also I must explicitly mention that there are no plans of switching to non-LTS JDK versions.

danslapman commented 2 months ago

Closing since docs does exist. Feel free to ask if there will be more questions