|
|
|
@ -1,21 +1,20 @@
|
|
|
|
|
package builderpackage;
|
|
|
|
|
|
|
|
|
|
import aiyh.utils.tool.cn.hutool.core.util.StrUtil;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
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<String> blackList = new ArrayList<>();
|
|
|
|
|
List<String> blacklistPrefixes = Arrays.asList(
|
|
|
|
|
"target" + File.separator + "generated-sources",
|
|
|
|
|
"target" + File.separator + "generated-test-sources",
|
|
|
|
@ -25,7 +24,26 @@ public class FileTreeBuilder {
|
|
|
|
|
"target" + File.separator + "classes" + File.separator + "ln",
|
|
|
|
|
"target" + File.separator + "classes" + File.separator + "cus_getlog"
|
|
|
|
|
);
|
|
|
|
|
return buildFileTreeRecursively(root, blacklistPrefixes);
|
|
|
|
|
Properties properties = new Properties();
|
|
|
|
|
try (InputStream inputStream = FileTreeBuilder.class.getClassLoader().getResourceAsStream("application.properties")) {
|
|
|
|
|
properties.load(inputStream);
|
|
|
|
|
// 通过键获取属性值
|
|
|
|
|
String value = properties.getProperty("packageBlackPaths");
|
|
|
|
|
if (StrUtil.isNotBlank(value)) {
|
|
|
|
|
String[] split = value.split(";");
|
|
|
|
|
Collections.addAll(blackList, split);
|
|
|
|
|
}
|
|
|
|
|
directoryPath = properties.getProperty("packageRootPath");
|
|
|
|
|
blackList.addAll(blacklistPrefixes);
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
File root = new File(directoryPath);
|
|
|
|
|
if (!root.exists() || !root.isDirectory()) {
|
|
|
|
|
System.out.println("Invalid directory path: " + directoryPath);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return buildFileTreeRecursively(root, blackList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static FileInfo buildFileTree(String directoryPath, List<String> blacklistPrefixes) {
|
|
|
|
@ -104,9 +122,4 @@ public class FileTreeBuilder {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
String directoryPath = "target/";
|
|
|
|
|
FileInfo fileTree = buildFileTree(directoryPath);
|
|
|
|
|
printFileTree(fileTree, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|