wilx commented on code in PR #1075:
URL: 
https://github.com/apache/maven-compiler-plugin/pull/1075#discussion_r3666495496


##########
src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java:
##########
@@ -1559,8 +1559,25 @@ private Set<File> computeStaleSources(
             }
 
             try {
-                staleSources.addAll(scanner.getIncludedSources(rootFile, 
outputDirectory));
-            } catch (InclusionScanException e) {
+                Set<File> includedSources = 
scanner.getIncludedSources(rootFile, outputDirectory);
+                // The stale source scanner assumes that every source produces 
an output file. Filter its result only
+                // when the compiler provides an individual source-to-output 
mapping; aggregate outputs are ambiguous.
+                if (outputStyle == 
CompilerOutputStyle.ONE_OUTPUT_FILE_PER_INPUT_FILE) {
+                    for (File source : includedSources) {
+                        String relativePath =
+                                
rootFile.toPath().relativize(source.toPath()).toString();
+                        boolean outputExists = 
mapping.getTargetFiles(outputDirectory, relativePath).stream()

Review Comment:
   > While `java.io.File` (and Java's NIO layer on Windows) can parse 
backslashes, Maven plugins like `maven-war-plugin` or `maven-ear-plugin` do not 
just write files to disk—they map them into **archives (ZIP, JAR, WAR, EAR)**.
   > 
   >     1. **Archive Entry Standards:** ZIP and JAR specifications mandate 
that entry names use forward slashes (`/`) as path separators, regardless of 
the host operating system.
   > 
   >     2. **Map/Cache Lookups:** If target paths are stored as keys in a 
`Map` or `Set` (e.g., to track packaged or copied files, check for staleness, 
or prevent duplicates), a path string containing `\` on Windows will not match 
an entry lookup using `/`. This leads to cross-platform bugs where builds 
behave differently on Windows versus Unix.
   > 
   >     3. **Java's `File` Flexibility:** Ironically, Java's `File` 
constructor on Windows accepts forward slashes (`/`) natively and normalizes 
them internally. Therefore, forcing platform-specific separators via 
`Path#toString()` introduces risks for map keys and archive matching without 
providing any functional benefit to the `File` constructor itself.
   > 
   > 
   > The finding is valid; relying on `Path#toString()` for target mappings in 
archive-building plugins frequently causes Windows-specific regressions.
   
   I am sorry, but this is irrelevant in the face of what the 
`org.codehaus.plexus.compiler.util.scan.mapping.SourceMapping` implementations 
actually do. The AI is wrong. 



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