fix: enable build cache reuse across machines#1651
Open
NikolayMetchev wants to merge 3 commits intoautonomousapps:mainfrom
Open
fix: enable build cache reuse across machines#1651NikolayMetchev wants to merge 3 commits intoautonomousapps:mainfrom
NikolayMetchev wants to merge 3 commits intoautonomousapps:mainfrom
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1083
PathSensitivity.ABSOLUTEtoPathSensitivity.NONEonArtifactsReportTask.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).ExplodedJar.jarFile— set fromPhysicalArtifact.filebut never accessed after serialization. Eliminating it removes absolute paths fromExplodeJarTask's output.Dependency.files— explicitly marked in code as "unused and was only added speculatively". Eliminating it removes absolute paths fromSynthesizeDependenciesTask's output.Why this is safe
When
ArtifactsReportTaskgets 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
NONEand notRELATIVE?PathSensitivity.NONEmeans 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), soRELATIVEwould not help.Test plan
./gradlew compileKotlinpassesjarFileorfilesfields🤖 Generated with Claude Code