tfactor2 commented on code in PR #498:
URL:
https://github.com/apache/maven-build-cache-extension/pull/498#discussion_r3470097609
##########
src/main/java/org/apache/maven/buildcache/CacheControllerImpl.java:
##########
@@ -677,50 +675,20 @@ public void save(
}
/**
- * Saves a project artifact to cache, handling both regular files and
directory artifacts.
- * Directory artifacts (e.g., target/classes from compile-only builds) are
zipped before saving
- * since Files.copy() cannot handle directories.
+ * Saves a project artifact to cache.
*/
private void saveProjectArtifact(
CacheResult cacheResult, org.apache.maven.artifact.Artifact
projectArtifact, MavenProject project)
throws IOException {
File originalFile = projectArtifact.getFile();
try {
- if (originalFile.isDirectory()) {
- saveDirectoryArtifact(cacheResult, projectArtifact, project,
originalFile);
- } else {
- // Regular file (JAR/WAR) - save directly
- localCache.saveArtifactFile(cacheResult, projectArtifact);
- }
+ localCache.saveArtifactFile(cacheResult, projectArtifact);
} finally {
// Restore original file reference in case it was temporarily
changed
projectArtifact.setFile(originalFile);
}
}
- /**
- * Saves a directory artifact by zipping it first, then saving the zip to
cache.
- */
- private void saveDirectoryArtifact(
Review Comment:
[explanation] #Why `saveDirectoryArtifact(...)` is removed:
The method made a directory-backed Maven project artifact saveable by
zipping it and storing it through the main artifact path. That preserved the
invalid metadata shape that caused #449: `target/classes` is a compile output
directory, not the project's packaged main artifact.
With this change, `saveProjectArtifact(...)` only saves regular files
produced by package-or-later mojos. Compile outputs are still cached, but
through `attachCompileOutputs(...)` / attached output archives, so jar modules
keep compile-cache benefits without letting `target/classes` poison later
`package` or `install` executions.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]