Skip to content

fix: enable build cache reuse across machines#1651

Open
NikolayMetchev wants to merge 3 commits intoautonomousapps:mainfrom
NikolayMetchev:fix/cache-misses-ci-local-1083
Open

fix: enable build cache reuse across machines#1651
NikolayMetchev wants to merge 3 commits intoautonomousapps:mainfrom
NikolayMetchev:fix/cache-misses-ci-local-1083

Conversation

@NikolayMetchev
Copy link
Copy Markdown

Summary

Fixes #1083

  • Change PathSensitivity.ABSOLUTE to PathSensitivity.NONE on ArtifactsReportTask.getClasspathArtifactFiles(), so the build cache key is based on file content rather than filesystem path. This enables cache hits between CI and local builds (and across any machines with different Gradle home locations).
  • Remove ExplodedJar.jarFile — set from PhysicalArtifact.file but never accessed after serialization. Eliminating it removes absolute paths from ExplodeJarTask's output.
  • Remove Dependency.files — explicitly marked in code as "unused and was only added speculatively". Eliminating it removes absolute paths from SynthesizeDependenciesTask's output.

Why this is safe

When ArtifactsReportTask gets a cache hit, its output (PhysicalArtifact JSON) is restored verbatim. All downstream tasks (ExplodeJarTask, FindKotlinMagicTask, ComputeDominatorTreeTask, SynthesizeDependenciesTask) see identical input content, so they also get cache hits. Nobody tries to use the absolute paths at runtime. The entire chain caches together coherently.

Why NONE and not RELATIVE?

PathSensitivity.NONE means Gradle ignores the file's path entirely and only fingerprints its content. This is appropriate here because jars live in the Gradle user home (outside the project directory), so RELATIVE would not help.

Test plan

  • ./gradlew compileKotlin passes
  • Full test suite passes
  • Verify intermediate JSON outputs no longer contain jarFile or files fields

🤖 Generated with Claude Code

NikolayMetchev and others added 3 commits March 1, 2026 11:21
Change PathSensitivity from ABSOLUTE to NONE on ArtifactsReportTask's
input, so the cache key is based on file content rather than filesystem
path. This enables cache hits between CI and local builds.

Also remove unused absolute-path fields from intermediate outputs:
- ExplodedJar.jarFile: never accessed after serialization
- Dependency.files: explicitly marked as unused/speculative

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Guard against re-introducing absolute file paths into cached intermediate
JSON outputs (exploded-jars, dependencies), which would break cross-machine
build cache reuse.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The removal of jarFile left compareTo() comparing only by coordinates,
causing TreeSet to silently drop duplicate jars with the same coordinates
but different content (classifiers, transforms). Use binaryClasses as a
content-based tiebreaker to preserve all jars.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

Cache misses between CI and local

1 participant