Skip to content

Allow to run native:compile and native:compile-no-fork from the command-line #273

@snicoll

Description

@snicoll

Is your feature request related to a problem? Please describe.
It is not possible to run ./mvnw native:build consistently from the command-line. If you run this goal from a project that you've never built before (i.e. target does not exist yet), this yield the following:

[ERROR] Failed to execute goal org.graalvm.buildtools:native-maven-plugin:0.9.13:build (default-cli) on project demo: Execution default-cli of goal org.graalvm.buildtools:native-maven-plugin:0.9.13:build failed: Cannot invoke "java.io.File.exists()" because "artifactFile" is null

However, if package has run before (potentially with outdated source) it will pick the state of the "latest" time package ran. To avoid that from happening, one can run ./mvnw package native:build.

Describe the solution you'd like
There is a way to instruct a goal that it has to run a phase first. Core maven plugins use this feature so that invoking the goal alone is all that it takes to produces an accurate result.

Spring Boot uses this feature as well for their buildpack integration (i.e. ./mvnw spring-boot:build-image will first build the application and then invoke buildpack on the updated repackaged archive).

This makes then the goal not really suitable to being added to a lifecycle execution, as package would then run twice. Core plugins implement a no-fork goal that does exactly the same thing as the original goal, except it doesn't execute the phase that it needs.

Spring Boot would like to provide a native profile that configures both our buildpack integration, and our NBT integration so that users can choose the tool they want. They can currently run ./mvnw -Pnative spring-boot:build-native. However ./mvnw -Pnative native:build does not work as expected for the reason explained above.

Describe alternatives you've considered
The alternative would be inconsistent command-line options where NBT requires an extra package.

Additional context
See spring-projects/spring-boot#31770

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions