Skip to content

Fix: Store checkNativeImageNoAwt and runNativeImageAgent in the configuration cache - #76

Open
b-re-w wants to merge 1 commit into
extendedfrom
fix/native-image-config-cache
Open

b-re-w wants to merge 1 commit into
extendedfrom
fix/native-image-config-cache

Conversation

@b-re-w

@b-re-w b-re-w commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Fixes #74.

Problem. Two native-image tasks read the application object at execution time, so the configuration cache had to store the whole application with them, including the Kotlin target and its source set:

  • checkNativeImageNoAwt's onlyIf reads app.windowing.
  • runNativeImageAgent's doFirst reads app.mainClass and app.args.

On Gradle 8.13, Gemstone (LogitAI/Gemstone JetBrains#255, plugin 1.11.1-ext.3) got Cannot run Project.afterEvaluate(Action) when the project is already evaluated and now runs both tasks with --no-configuration-cache. On 8.13 and 9.3.1 the configuration cache problem report names DefaultSourceSet for both tasks.

Change.

  • CheckNativeImageNoAwtTask gains an @Input windowing property. The plugin sets it from the application, and onlyIf reads the task's own property.
  • runNativeImageAgent reads the main class and arguments through project.provider { }. The configuration cache stores their values, not the application.

Test, red first. NativeImageConfigurationCacheTest is new in the integration tests. Its test project application/nativeImageConfigurationCache has output = ApplicationOutput.NativeImage.

  • It runs packageNativeImage --dry-run and runNativeImageAgent --dry-run twice each, with the configuration cache on. A dry run stores the task graph like a real run, so no GraalVM is needed.
  • It checks for Configuration cache entry stored. on the first run and Reusing configuration cache. on the second.

Local runs (macOS arm64).

Gradle Before the change After the change
8.13 (Gemstone's version), run with -Pcompose.tests.gradle.versions='8.13, 9.3.1' both tests fail, with the problems above both pass
9.3.1 both tests fail, with the problems above both pass

The existing NativeImage* unit tests pass too.

On 8.13, my --tests filter wasn't passed to that task, so the whole integration suite ran there. 79 of its other tests failed in that unfiltered run. This PR doesn't touch them, and 8.13 isn't in the plugin's tested compose.tests.gradle.versions (9.3.1, 9.5.0).

🤖 Generated with Claude Code

…ion cache

checkNativeImageNoAwt's onlyIf and runNativeImageAgent's doFirst read the
application (app.windowing, app.mainClass, app.args), so the configuration
cache stored the application with them, and with it the Kotlin target and its
source set. On Gradle 8.13 storing failed with "Cannot run
Project.afterEvaluate(Action) when the project is already evaluated" (found by
Gemstone, which runs both with --no-configuration-cache); on 8.13 and 9.3.1 the
problem report names DefaultSourceSet.

The check task takes the windowing as an input and its spec reads the task;
the agent reads the main class and arguments through providers.

NativeImageConfigurationCacheTest dry-runs both tasks twice in a native image
project with the configuration cache on, and checks the entry is stored and
then reused. It failed on Gradle 8.13 and 9.3.1 before and passes on both.

Fixes #74

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant