reproduce: https://github.com/mgzu/boot-demo command:

./gradlew :app-web-business:app-order:nativeCompile

log:

[native-image-plugin] GraalVM Toolchain detection is enabled
[native-image-plugin] Native Image executable was installed using 'gu' tool
[native-image-plugin] GraalVM uses toolchain detection. Selected:
[native-image-plugin]    - language version: 17
[native-image-plugin]    - vendor: GraalVM Community
[native-image-plugin]    - runtime version: 17.0.5+8-jvmci-22.3-b08
[native-image-plugin] Native Image executable path: /usr/local/sdkman/candidates/java/22.3.r17-grl/lib/svm/bin/native-image
Error: Please specify class (or <module>/<mainclass>) containing the main entry point method. (see --help)

> Task :app-web-business:app-order:nativeCompile FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app-web-business:app-order:nativeCompile'.
> Process 'command '/usr/local/sdkman/candidates/java/22.3.r17-grl/bin/native-image'' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 35s
26 actionable tasks: 1 executed, 25 up-to-date

Comment From: wilkinsona

The problem's caused by your plugin configuration in the root project, specifically this:

plugins {
    id 'org.springframework.boot' version "${springBootVersion}" apply false
    id 'java'
}

This results in Spring Boot's plugin being loaded in a class loader that cannot see the native image plugin. As a result, it cannot react to the native image plugin being applied in :app-web-business:app-order so native image compilation is not configured correctly.

You can fix the problem by declaring the native image plugin in the root project without applying it. This ensures that both plugins are loaded in the same class loader:

plugins {
    id 'org.springframework.boot' version "${springBootVersion}" apply false
    id 'org.graalvm.buildtools.native' version "${nativeBuildToolsVersion}" apply false
    id 'java'
}