Fixes #478
What changed
This PR fixes custom Gradle application binaries so they inherit the expected runtime classpath and metadata exclusion wiring.
Before this change, custom binaries created through graalvmNative.binaries could miss the main runtime classpath by default and could also miss reachability metadata exclusion handling.
After this change, custom application binaries follow the main runtime classpath model unless a more specific source set or image mode says otherwise, and metadata exclusions continue to flow into the generated native-image command line.
Why
Custom binaries should behave like first-class Gradle Native Build Tools binaries. Without this fix, users could get confusing classpath differences or missing metadata exclusion behavior when defining extra application binaries.
Example
Before:
A custom binary such as qa could be created successfully, but its generated compile/run tasks might not see the expected runtime classpath or metadata exclusions that the main binary would get.
After:
A custom application binary such as qa uses the expected runtime classpath model and carries metadata exclusions through to the generated native-image invocation.
Implementation summary
- Initialize custom application binaries from the main runtime classpath model when no explicit native-image classpath configuration already exists.
- Carry the existing metadata exclusion argument provider into those custom binaries.
- Keep test binaries and
createLayer binaries on their specialized classpath paths.
- Add unit and functional regression coverage for custom binary classpath and metadata exclusion behavior.
- Update the Gradle functional specs for custom binary classpath and compile-task input behavior.
Validation
JAVA_HOME=/home/jovan/.sdkman/candidates/java/17.0.12-graal GRAALVM_HOME=/home/jovan/.sdkman/candidates/java/17.0.12-graal ./gradlew :native-gradle-plugin:test --tests org.graalvm.buildtools.gradle.NativeImagePluginTest
JAVA_HOME=/home/jovan/.sdkman/candidates/java/17.0.12-graal GRAALVM_HOME=/home/jovan/.sdkman/candidates/java/17.0.12-graal ./gradlew :native-gradle-plugin:inspections
JAVA_HOME=/home/jovan/.sdkman/candidates/java/17.0.12-graal GRAALVM_HOME=/home/jovan/.sdkman/candidates/java/21.0.10-graal ./gradlew :native-gradle-plugin:functionalTest --tests "org.graalvm.buildtools.gradle.NativeConfigRepoFunctionalTest.custom binary uses runtime classpath and metadata exclusions" --info
/home/jovan/.local/bin/grund fmt native-gradle-plugin --marker --check
git diff --check