Copilot commented on code in PR #498:
URL: 
https://github.com/apache/maven-build-cache-extension/pull/498#discussion_r3469961032


##########
src/main/java/org/apache/maven/buildcache/CacheControllerImpl.java:
##########
@@ -1323,13 +1335,15 @@ private Set<Path> 
collectCachedArtifactPaths(MavenProject project) {
         final org.apache.maven.artifact.Artifact projectArtifact = 
project.getArtifact();
         final Path targetDir = Paths.get(project.getBuild().getDirectory());
 
-        // 1. Main project artifact (JAR file or target/classes directory)
-        if (projectArtifact.getFile() != null && 
projectArtifact.getFile().exists()) {
+        // 1. Main project artifact (JAR/WAR/etc. file)
+        if (projectArtifact.getFile() != null && 
projectArtifact.getFile().isFile()) {
             paths.add(projectArtifact.getFile().toPath());
         }
 
-        // 2. Attached outputs from configuration (if cacheCompile enabled)
+        // 2. Compile outputs and configured attached outputs (if cacheCompile 
enabled)
         if (cacheConfig.isCacheCompile()) {
+            addExistingOutputPath(paths, 
project.getBuild().getOutputDirectory());
+            addExistingOutputPath(paths, 
project.getBuild().getTestOutputDirectory());
             List<DirName> attachedDirs = cacheConfig.getAttachedOutputs();

Review Comment:
   collectCachedArtifactPaths() now adds build output directories via 
Paths.get(outputDirectory) without validating they are within the project. If 
outputDirectory is configured outside the project (or resolves outside due to 
relative paths), stagePreExistingArtifacts() will later throw on 
multimoduleRoot.relativize(path) or could move arbitrary filesystem paths into 
the staging dir. Align this with attachOutputs()/attachCompileOutput() by 
discarding output paths that are outside the project (and do the same for 
configured attached outputs).



-- 
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]

Reply via email to