From 6593b3b59a1a0c85d8534417b4682c8e65bdb1be Mon Sep 17 00:00:00 2001 From: "youhong.ai" Date: Tue, 4 Jul 2023 16:31:08 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=89=93=E5=8C=85=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E6=B7=BB=E5=8A=A0=E9=BB=91=E5=90=8D=E5=8D=95=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/java/BuilderPackageEcology.java | 2 +- .../java/builderpackage/FileTreeBuilder.java | 25 +++++++------------ 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/test/java/BuilderPackageEcology.java b/src/test/java/BuilderPackageEcology.java index 1209f6a..ae43a2c 100644 --- a/src/test/java/BuilderPackageEcology.java +++ b/src/test/java/BuilderPackageEcology.java @@ -31,7 +31,7 @@ public class BuilderPackageEcology extends Application { public void start(Stage primaryStage) { primaryStage.setTitle("EBU7部开发一部自动打包工具"); - FileInfo fileInfo = FileTreeBuilder.buildFileTree("target/"); + FileInfo fileInfo = FileTreeBuilder.buildFileTree(); rootItem = createTreeItem(fileInfo); treeView = new TreeView<>(rootItem); diff --git a/src/test/java/builderpackage/FileTreeBuilder.java b/src/test/java/builderpackage/FileTreeBuilder.java index b2cbabb..3d5072a 100644 --- a/src/test/java/builderpackage/FileTreeBuilder.java +++ b/src/test/java/builderpackage/FileTreeBuilder.java @@ -12,13 +12,9 @@ public class FileTreeBuilder { public static final String DIRECTORY_TYPE = "文件夹"; public static final String FILE_TYPE = "文件"; - public static FileInfo buildFileTree(String directoryPath) { - File root = new File(directoryPath); - if (!root.exists() || !root.isDirectory()) { - System.out.println("Invalid directory path: " + directoryPath); - return null; - } - + public static FileInfo buildFileTree() { + String directoryPath = "target/"; + List blackList = new ArrayList<>(); List blacklistPrefixes = Arrays.asList( "target" + File.separator + "generated-sources", "target" + File.separator + "generated-test-sources", @@ -29,8 +25,6 @@ public class FileTreeBuilder { "target" + File.separator + "classes" + File.separator + "cus_getlog" ); Properties properties = new Properties(); - - List blackList = new ArrayList<>(); try (InputStream inputStream = FileTreeBuilder.class.getClassLoader().getResourceAsStream("application.properties")) { properties.load(inputStream); // 通过键获取属性值 @@ -39,12 +33,16 @@ public class FileTreeBuilder { String[] split = value.split(";"); Collections.addAll(blackList, split); } + directoryPath = properties.getProperty("packageRootPath"); blackList.addAll(blacklistPrefixes); - System.out.println("Value: " + value); } catch (IOException e) { e.printStackTrace(); } - System.out.println(blackList); + File root = new File(directoryPath); + if (!root.exists() || !root.isDirectory()) { + System.out.println("Invalid directory path: " + directoryPath); + return null; + } return buildFileTreeRecursively(root, blackList); } @@ -124,9 +122,4 @@ public class FileTreeBuilder { } } - public static void main(String[] args) { - String directoryPath = "target/"; - FileInfo fileTree = buildFileTree(directoryPath); - printFileTree(fileTree, 0); - } }