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); - } }