Copilot commented on code in PR #493:
URL:
https://github.com/apache/maven-build-cache-extension/pull/493#discussion_r4430902939
##########
src/main/java/org/apache/maven/buildcache/CacheControllerImpl.java:
##########
@@ -1475,8 +1476,15 @@ private Set<Path>
collectCachedArtifactPaths(MavenProject project) {
paths.add(projectArtifact.getFile().toPath());
}
- // 2. Attached outputs from configuration (if cacheCompile enabled)
+ // 2. Compile output directory and attached outputs from configuration
(if cacheCompile enabled)
if (cacheConfig.isCacheCompile()) {
+ // The project artifact file is not set yet at the start of a
session, so step 1 misses
+ // target/classes. Stage it explicitly so the compiler cannot keep
classes compiled against
+ // a different version of an upstream module.
+ Path classesDir =
Paths.get(project.getBuild().getOutputDirectory());
+ if (Files.exists(classesDir)) {
+ paths.add(classesDir);
Review Comment:
This stages all existing `target/classes` contents even when the requested
goals do not rebuild them: on a cache miss, a direct `compiler:testCompile`
invocation loses the main classes it needs, while `compiler:compile` loses
previously copied resources. Pre-compile lifecycle invocations are also
affected, and `restoreStagedArtifacts()` discards the staged subtree when it
encounters an existing target ancestor rather than recovering those files. Make
staging aware of the execution plan so it preserves outputs that the requested
goals consume or do not regenerate, and add regression coverage for these
partial invocations.
--
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]