Fixes #702
What changed
This PR fixes custom Gradle native test binaries so they follow the selected custom source set runtime classpath instead of always falling back to the default testRuntimeClasspath.
Before this change, a custom native test binary registered with registerTestBinary could accidentally inherit the default test classpath and mask missing dependencies or configuration errors in the custom source set.
After this change, custom native test binaries derive their runtime classpath from the selected source set, while still keeping the expected JUnit native support and generated task wiring.
Why
Custom native test binaries should behave like the source set they were registered for. Without this fix, users could get passing custom native test setups only because the default test classpath leaked in underneath them.
Example
Before:
A custom test image such as integTest could appear to work even if its own source set dependencies were incomplete, because the default test classpath masked the problem.
After:
The same custom test image follows its own source set runtime classpath, so project, JUnit, and plugin-provided native test dependencies come from the intended configuration.
Implementation summary
- Add
FS-gradle-native-tests.1.1 for custom native test binaries.
- Use the selected source set runtime classpath configuration instead of always using
testRuntimeClasspath.
- Add functional regression coverage that checks custom test image classpaths include the expected custom source set and plugin-provided dependencies.
- Update the custom-test sample so it no longer inherits dependencies from the default
test configurations.
Validation
JAVA_HOME=/home/jovan/.sdkman/candidates/java/17.0.12-graal ./gradlew :native-gradle-plugin:functionalTest --tests "org.graalvm.buildtools.gradle.JavaApplicationWithTestsFunctionalTest.custom test image classpath follows custom source set"
JAVA_HOME=/home/jovan/.sdkman/candidates/java/17.0.12-graal ./gradlew :native-gradle-plugin:functionalTest --tests "org.graalvm.buildtools.gradle.JavaApplicationWithTestsFunctionalTest.can register a custom test image"
JAVA_HOME=/home/jovan/.sdkman/candidates/java/17.0.12-graal ./gradlew :native-gradle-plugin:test :native-gradle-plugin:inspections
JAVA_HOME=/home/jovan/.sdkman/candidates/java/17.0.12-graal ./gradlew :native-gradle-plugin:configCacheFunctionalTest --tests "org.graalvm.buildtools.gradle.JavaApplicationWithTestsFunctionalTest.custom test image classpath follows custom source set"
git diff --check
grund gradle/FS-gradle-native-tests.1.1 --brief