@@ -11,4 +11,5 @@ public class BpmConfigBean { | |||||
// 是否debug模式 | // 是否debug模式 | ||||
private boolean debug; | private boolean debug; | ||||
private String codeJavaPath; | private String codeJavaPath; | ||||
private int mode; | |||||
} | } |
@@ -22,15 +22,18 @@ import java.util.Map; | |||||
* 读取Idea信息的工具类 | * 读取Idea信息的工具类 | ||||
*/ | */ | ||||
public class IdeaUtil { | public class IdeaUtil { | ||||
private final static int MODE_POM = 1; | |||||
//获取工程中的Module文件 | //获取工程中的Module文件 | ||||
public static Map<String, String> getModules(String ideaPath) { | |||||
File file = new File(ideaPath + "/pom.xml"); | |||||
if (file.exists()) { | |||||
return getModulesFromPom(ideaPath, file); | |||||
public static Map<String, String> getModules(String ideaPath, int mode) { | |||||
if (mode == MODE_POM) { | |||||
File file = new File(ideaPath + "/pom.xml"); | |||||
if (file.exists()) { | |||||
return getModulesFromPom(ideaPath, file); | |||||
} | |||||
} else { | |||||
File file = new File(ideaPath + "/.idea/modules.xml"); | |||||
if (file.exists()) return getModulesFromModule(ideaPath, file); | |||||
} | } | ||||
file = new File(ideaPath + "/.idea/modules.xml"); | |||||
if (file.exists()) return getModulesFromModule(ideaPath, file); | |||||
return null; | return null; | ||||
} | } | ||||
@@ -62,14 +65,6 @@ public class IdeaUtil { | |||||
return map; | return map; | ||||
} | } | ||||
public static void main(String args[]) throws Exception { | |||||
Map<String, String> list = getModules("e:/jujia/git/6.0/smtweb2/smtweb-framework"); | |||||
for (Map.Entry<String, String> s : list.entrySet()) { | |||||
System.out.println(s.getKey() + "=" + s.getValue()); | |||||
} | |||||
} | |||||
@Data | @Data | ||||
@JsonIgnoreProperties(ignoreUnknown = true) | @JsonIgnoreProperties(ignoreUnknown = true) | ||||
@JacksonXmlRootElement(localName = "project") | @JacksonXmlRootElement(localName = "project") | ||||
@@ -99,7 +99,7 @@ public class CodeBuildHandler extends AbstractHandler { | |||||
packageName = "cc.smtweb.biz." + moduleName + ".web"; | packageName = "cc.smtweb.biz." + moduleName + ".web"; | ||||
} | } | ||||
BpmConfigBean bpmConfigBean = SpringUtil.getBean(BpmConfigBean.class); | BpmConfigBean bpmConfigBean = SpringUtil.getBean(BpmConfigBean.class); | ||||
Map<String, String> mapIdeaModules = IdeaUtil.getModules(bpmConfigBean.getCodeJavaPath()); | |||||
Map<String, String> mapIdeaModules = IdeaUtil.getModules(bpmConfigBean.getCodeJavaPath(), bpmConfigBean.getMode()); | |||||
if (mapIdeaModules == null || mapIdeaModules.isEmpty()) throw new BizException("没有定义idea项目的路径(smtweb.bpm.codeJavaPath)!"); | if (mapIdeaModules == null || mapIdeaModules.isEmpty()) throw new BizException("没有定义idea项目的路径(smtweb.bpm.codeJavaPath)!"); | ||||
codePath = mapIdeaModules.get(moduleName); | codePath = mapIdeaModules.get(moduleName); | ||||
if (StringUtils.isEmpty(codePath)) { | if (StringUtils.isEmpty(codePath)) { | ||||
@@ -373,8 +373,8 @@ public class ModelFormHelper { | |||||
if (StringUtils.isEmpty(moduleName)) return null; | if (StringUtils.isEmpty(moduleName)) return null; | ||||
BpmConfigBean bpmConfigBean = SpringUtil.getBean(BpmConfigBean.class); | BpmConfigBean bpmConfigBean = SpringUtil.getBean(BpmConfigBean.class); | ||||
Map<String, String> mapIdeaModules = IdeaUtil.getModules(bpmConfigBean.getCodeJavaPath()); | |||||
if (mapIdeaModules.isEmpty()) throw new BizException("没有定义idea项目的路径(smtweb.bpm.codeJavaPath)!"); | |||||
Map<String, String> mapIdeaModules = IdeaUtil.getModules(bpmConfigBean.getCodeJavaPath(), bpmConfigBean.getMode()); | |||||
if (mapIdeaModules == null || mapIdeaModules.isEmpty()) throw new BizException("没有定义idea项目的路径(smtweb.bpm.codeJavaPath)!"); | |||||
String codeJavaPath = mapIdeaModules.get(moduleName); | String codeJavaPath = mapIdeaModules.get(moduleName); | ||||
if (StringUtils.isEmpty(codeJavaPath)) { | if (StringUtils.isEmpty(codeJavaPath)) { | ||||
throw new BizException("没有找到对应项目在idea中Module的路径(" + moduleName + ")!"); | throw new BizException("没有找到对应项目在idea中Module的路径(" + moduleName + ")!"); | ||||
@@ -15,7 +15,7 @@ import java.util.Map; | |||||
public class TestMain { | public class TestMain { | ||||
public static void main(String[] args) throws Exception { | public static void main(String[] args) throws Exception { | ||||
Map<String, String> map = IdeaUtil.getModules("d:/work/smtweb2/smtweb-framework"); | |||||
// Map<String, String> map = IdeaUtil.getModules("d:/work/smtweb2/smtweb-framework", 1); | |||||
} | } | ||||
} | } |