From 3478fb06032c32f1c38187505a1b34fb6983b56b Mon Sep 17 00:00:00 2001 From: zhenggm Date: Tue, 26 Jul 2022 17:23:51 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BB=E5=8F=96idea=E7=9A=84module=EF=BC=8C?= =?UTF-8?q?=E4=BC=98=E5=85=88=E8=AF=BB=E5=8F=96pom?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cc/smtweb/system/bpm/util/IdeaUtil.java | 36 +++++++++++++++++++++- .../framework/core/db/impl/DatabaseUtil.java | 1 + 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/IdeaUtil.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/IdeaUtil.java index 7ef1883..a30f431 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/IdeaUtil.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/IdeaUtil.java @@ -24,8 +24,32 @@ import java.util.Map; public class IdeaUtil { //获取工程中的Module文件 public static Map getModules(String ideaPath) { + File file = new File(ideaPath + "/pom.xml"); + if (file.exists()) { + return getModulesFromPom(ideaPath, file); + } + + file = new File(ideaPath + "/.idea/modules.xml"); + if (file.exists()) return getModulesFromModule(ideaPath, file); + return null; + } + + public static Map getModulesFromPom(String ideaPath, File file) { + Map map = new HashMap<>(); + PomProject project = XmlUtil.readValue(file, PomProject.class); + if (project == null || project.modules == null) return map; + for (String module: project.modules) { + File f = new File(ideaPath + "/" + module); + String s = f.getName(); + int i = s.lastIndexOf("."); + if (i >= 0) s = s.substring(0, i); + map.put(s, f.getAbsolutePath()); + } + return map; + } + public static Map getModulesFromModule(String ideaPath, File file) { Map map = new HashMap<>(); - IdeaProject project = XmlUtil.readValue(new File(ideaPath + "/.idea/modules.xml"), IdeaProject.class); + IdeaProject project = XmlUtil.readValue(file, IdeaProject.class); if (project == null || project.component == null || project.component.modules == null) return map; for (Module module: project.component.modules) { String s = module.filepath.replace("$PROJECT_DIR$", ideaPath); @@ -49,6 +73,16 @@ public class IdeaUtil { @Data @JsonIgnoreProperties(ignoreUnknown = true) @JacksonXmlRootElement(localName = "project") + public static class PomProject { + @JacksonXmlElementWrapper(localName = "modules") + @JacksonXmlProperty(localName = "module") + public List modules; + + } + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + @JacksonXmlRootElement(localName = "project") public static class IdeaProject { private Component component; diff --git a/smtweb-framework/core/src/main/java/cc/smtweb/framework/core/db/impl/DatabaseUtil.java b/smtweb-framework/core/src/main/java/cc/smtweb/framework/core/db/impl/DatabaseUtil.java index f73b50d..3ca277f 100644 --- a/smtweb-framework/core/src/main/java/cc/smtweb/framework/core/db/impl/DatabaseUtil.java +++ b/smtweb-framework/core/src/main/java/cc/smtweb/framework/core/db/impl/DatabaseUtil.java @@ -41,6 +41,7 @@ public class DatabaseUtil { public void checkDb() { UtilTime timer = new UtilTime(); timer.setLog(true); + timer.timerString("Start - 开始获取连接的数据库的元信息!"); this.databaseInfo.printDatabaseInfo(); // get ALL tables from this database