Skip to content

Fix schema directory ordering in Gradle cache keys - #981

Merged
iuliiasobolevska merged 1 commit into
masterfrom
fix/schema-directory-cache-order
Oct 9, 2026
Merged

iuliiasobolevska merged 1 commit into
masterfrom
fix/schema-directory-cache-order

Conversation

@iuliiasobolevska

@iuliiasobolevska iuliiasobolevska commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Schema directories named x.graphqls and x.graphqls! can share a Gradle build cache key with an ordinary directory layout even though fresh generation produces a different field and constructor parameter order.
Restoring the wrong classes can silently exchange values in positional constructor calls when the affected parameters have the same type.

Add a scalar schemaRootOrder input that records the root permutation using the actual directory types.
Gradle evaluates this input after producer tasks run, so roots created by earlier tasks are classified correctly without making their initial absence a configuration cache input.
The existing orderedSchemaRoots property and 8.7.0 generation order are preserved.
The KDoc distinguishes the name-based orderedSchemaRoots heuristic from execution-time directory classification in schemaRootOrder.

Verification

  • The four original directory regression cases fail on the original implementation with FROM_CACHE where execution is required.
  • Eight regression cases cover directory-only and mixed file/directory roots for .graphql and .graphqls, existing and producer-created roots, field order, constructor parameter order, fresh output equivalence and correct restoration with configuration cache reuse.
  • Omitting the scalar order input fails all eight cases with expected SUCCESS but was FROM_CACHE.
  • Four additional cases verify cache reuse across relocated workspaces and reversed configured root order, including producer-created roots and reused configuration caches.
  • Taking permutation indices from configured roots fails all four relocation cases with expected FROM_CACHE but was SUCCESS.
  • An absolute-path mutation of the scalar input fails all four relocation cases with expected FROM_CACHE but was SUCCESS.
  • All 28 cases in GenerateJavaTaskBuildCacheTest pass with the fix.
  • Kotlin formatting, lint and validatePlugins pass.

Windows validation

OpenJDK 17's Windows File.compareTo implementation was inspected: WinNTFileSystem.compare uses String.compareToIgnoreCase.
CodeGen.discoverSchemaSources sorts File values, while both the existing orderedSchemaRoots heuristic and the new schemaRootOrder input sort strings case-sensitively.
This comparator difference predates this PR.
The cache tests ran on macOS; no Windows build or cache restoration test was run.

@iuliiasobolevska iuliiasobolevska added the bug Something isn't working label Oct 7, 2026
@iuliiasobolevska
iuliiasobolevska force-pushed the fix/schema-directory-cache-order branch from aebe587 to 8b34d84 Compare October 7, 2026 19:52
@iuliiasobolevska
iuliiasobolevska force-pushed the fix/schema-directory-cache-order branch from 8b34d84 to 6a335f1 Compare October 7, 2026 20:14
@iuliiasobolevska
iuliiasobolevska marked this pull request as ready for review October 8, 2026 17:05
@iuliiasobolevska
iuliiasobolevska merged commit c0fe639 into master Oct 9, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants