Use platform-neutral path composition
This commit is contained in:
@@ -515,7 +515,7 @@ public class ApiDocWindow {
|
||||
Path projDir = Paths.get(projPath);
|
||||
if (!Files.isDirectory(projDir)) continue;
|
||||
List<Path> srcBases = new ArrayList<>();
|
||||
Path selfSrc = projDir.resolve("src/main/java");
|
||||
Path selfSrc = projDir.resolve(Path.of("src", "main", "java"));
|
||||
if (Files.isDirectory(selfSrc)) srcBases.add(selfSrc);
|
||||
try (Stream<Path> children = Files.list(projDir)) {
|
||||
children.filter(Files::isDirectory)
|
||||
@@ -579,7 +579,7 @@ public class ApiDocWindow {
|
||||
for (String projPath : selectedPaths) {
|
||||
Path projDir = Paths.get(projPath);
|
||||
if (!Files.isDirectory(projDir)) continue;
|
||||
Path selfSrc = projDir.resolve("src/main/java");
|
||||
Path selfSrc = projDir.resolve(Path.of("src", "main", "java"));
|
||||
String key = selfSrc.toString().replace('\\', '/');
|
||||
if (Files.isDirectory(selfSrc) && seenSrcBases.add(key)) {
|
||||
modules.add(new ModuleInfo(projDir.getFileName().toString(), projPath, selfSrc));
|
||||
@@ -905,7 +905,7 @@ public class ApiDocWindow {
|
||||
|
||||
private void collectSrcBases(Path dir, List<Path> srcBases) {
|
||||
if (!Files.isDirectory(dir)) return;
|
||||
Path sb = dir.resolve("src/main/java");
|
||||
Path sb = dir.resolve(Path.of("src", "main", "java"));
|
||||
if (Files.isDirectory(sb)) srcBases.add(sb);
|
||||
try (Stream<Path> children = Files.list(dir)) {
|
||||
children.filter(Files::isDirectory).filter(d -> !d.getFileName().toString().startsWith("."))
|
||||
@@ -932,7 +932,7 @@ public class ApiDocWindow {
|
||||
|
||||
private void collectModules(Path dir, List<ModuleInfo> modules, Set<String> seen) {
|
||||
if (!Files.isDirectory(dir)) return;
|
||||
Path sb = dir.resolve("src/main/java");
|
||||
Path sb = dir.resolve(Path.of("src", "main", "java"));
|
||||
String key = sb.toString().replace('\\', '/');
|
||||
if (Files.isDirectory(sb) && seen.add(key)) {
|
||||
modules.add(new ModuleInfo(dir.getFileName().toString(),
|
||||
|
||||
@@ -81,7 +81,7 @@ public class JavaSourceParser {
|
||||
* 扫描项目目录下所有 .java 文件(自动追加 src/main/java)
|
||||
*/
|
||||
public List<Path> findJavaFiles(Path projectPath) {
|
||||
Path javaSrc = projectPath.resolve("src/main/java");
|
||||
Path javaSrc = projectPath.resolve(Path.of("src", "main", "java"));
|
||||
if (!Files.isDirectory(javaSrc)) {
|
||||
log.debug("项目 {} 没有 src/main/java 目录", projectPath);
|
||||
return new ArrayList<>();
|
||||
|
||||
+3
-3
@@ -10,9 +10,9 @@ public final class OutputLayoutPolicy {
|
||||
Path root = requireProjectRoot(projectRoot);
|
||||
return new OutputLayout(
|
||||
root,
|
||||
root.resolve("src/main/java"),
|
||||
root.resolve("src/main/resources"),
|
||||
root.resolve("src/main/java"));
|
||||
root.resolve(Path.of("src", "main", "java")),
|
||||
root.resolve(Path.of("src", "main", "resources")),
|
||||
root.resolve(Path.of("src", "main", "java")));
|
||||
}
|
||||
|
||||
public OutputLayout custom(
|
||||
|
||||
@@ -71,7 +71,8 @@ public class FileOperationHelper {
|
||||
public String generateFileName(String baseDirectory, String prefix, String extension) {
|
||||
String timestamp = java.time.LocalDateTime.now()
|
||||
.format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd-HH-mm-ss"));
|
||||
return String.format("%s/%s_%s.%s", baseDirectory, prefix, timestamp, extension);
|
||||
String fileName = String.format("%s_%s.%s", prefix, timestamp, extension);
|
||||
return Paths.get(baseDirectory).resolve(fileName).toString();
|
||||
}
|
||||
|
||||
public String generateFileName(String prefix, String extension) {
|
||||
|
||||
Reference in New Issue
Block a user