This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/master by this push:
new eb8bbb53b6 GROOVY-12370: GroovyDocWriter: use '/' for resource
destination paths
eb8bbb53b6 is described below
commit eb8bbb53b6a58980fe32e5d84ae27d920a7f8eeb
Author: Daniel Sun <[email protected]>
AuthorDate: Mon Sep 7 02:31:19 2026 +0900
GROOVY-12370: GroovyDocWriter: use '/' for resource destination paths
copyTree passed Path#toString() to OutputTool, which is '\' on Windows.
MockOutputTool looks up by exact string, and the rest of GroovyDocWriter
already uses '/', so a copied doc-files asset was stored under a backslash
path and testDocFilesSymlinkIsNotCopiedIntoOutput could not find it.
Normalise the destination to '/' so resource copies match
writeClassToOutput.
The regression test now also matches copied keys independently of separator,
so a symlink copy cannot hide behind a backslash key on Windows.
---
.../org/codehaus/groovy/tools/groovydoc/GroovyDocWriter.java | 8 +++++---
.../org/codehaus/groovy/tools/groovydoc/GroovyDocToolTest.java | 9 +++++----
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git
a/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/GroovyDocWriter.java
b/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/GroovyDocWriter.java
index 4826a7754a..a937e8e1d9 100644
---
a/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/GroovyDocWriter.java
+++
b/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/GroovyDocWriter.java
@@ -178,14 +178,16 @@ public class GroovyDocWriter {
}
Path rel = srcDir.relativize(srcFile);
Path dstFile = dstDir.resolve(rel);
+ // OutputTool destinations use '/' (see writeClassToOutput);
Path#toString is '\' on Windows
+ String dest = dstFile.toString().replace('\\', '/');
try {
if (Files.isDirectory(srcFile)) {
- output.makeOutputArea(dstFile.toString());
+ output.makeOutputArea(dest);
} else {
- output.copyResource(srcFile.toString(),
dstFile.toString());
+ output.copyResource(srcFile.toString(), dest);
}
} catch (Exception e) {
- log.warn("Failed to copy " + srcFile + " to " + dstFile +
": " + e.getMessage());
+ log.warn("Failed to copy " + srcFile + " to " + dest + ":
" + e.getMessage());
}
});
} catch (IOException e) {
diff --git
a/subprojects/groovy-groovydoc/src/test/groovy/org/codehaus/groovy/tools/groovydoc/GroovyDocToolTest.java
b/subprojects/groovy-groovydoc/src/test/groovy/org/codehaus/groovy/tools/groovydoc/GroovyDocToolTest.java
index d1cb0bb0f2..b43e691b50 100644
---
a/subprojects/groovy-groovydoc/src/test/groovy/org/codehaus/groovy/tools/groovydoc/GroovyDocToolTest.java
+++
b/subprojects/groovy-groovydoc/src/test/groovy/org/codehaus/groovy/tools/groovydoc/GroovyDocToolTest.java
@@ -432,10 +432,11 @@ public class GroovyDocToolTest extends GroovyTestCase {
String docFilesOut = MOCK_DIR + "/" + pkg + "/doc-files/";
// the symlink is not copied, so its target content never reaches the
output
- assertNull("a doc-files symlink was copied into the output",
- output.getText(docFilesOut + "leak.txt"));
- // a real asset in the same directory still is
- assertEquals("a real doc-files asset should still be copied",
+ assertFalse("a doc-files symlink was copied into the output: " +
output.getOutputs().keySet(),
+ output.getOutputs().keySet().stream()
+ .anyMatch(k -> k.replace('\\',
'/').endsWith("/doc-files/leak.txt")));
+ // a real asset in the same directory still is; dest paths use '/'
even on Windows
+ assertEquals("a real doc-files asset should still be copied; outputs="
+ output.getOutputs().keySet(),
"a real asset", output.getText(docFilesOut + "note.txt"));
}