Bläddra i källkod

读取idea的module,优先读取pom

master
郑根木 2 år sedan
förälder
incheckning
3478fb0603
2 ändrade filer med 36 tillägg och 1 borttagningar
  1. +35
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/IdeaUtil.java
  2. +1
    -0
      smtweb-framework/core/src/main/java/cc/smtweb/framework/core/db/impl/DatabaseUtil.java

+ 35
- 1
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/IdeaUtil.java Visa fil

@@ -24,8 +24,32 @@ import java.util.Map;
public class IdeaUtil {
//获取工程中的Module文件
public static Map<String, String> 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<String, String> getModulesFromPom(String ideaPath, File file) {
Map<String, String> 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<String, String> getModulesFromModule(String ideaPath, File file) {
Map<String, String> 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<String> modules;

}

@Data
@JsonIgnoreProperties(ignoreUnknown = true)
@JacksonXmlRootElement(localName = "project")
public static class IdeaProject {
private Component component;



+ 1
- 0
smtweb-framework/core/src/main/java/cc/smtweb/framework/core/db/impl/DatabaseUtil.java Visa fil

@@ -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


Laddar…
Avbryt
Spara