|
|
|
@ -10,12 +10,29 @@ public class PathUtils {
|
|
|
|
|
|
|
|
|
|
private static final String JAVA_FILE_SUFFIX = ".java";
|
|
|
|
|
|
|
|
|
|
public static String getProjectPath() {
|
|
|
|
|
return CONFIG.getString(CfgConsts.PROJECT_PATH_BASE);
|
|
|
|
|
public static String getProjectBasePath() {
|
|
|
|
|
return CONFIG.getString(CfgConsts.PROJECT_PATH_BASE).replaceAll("\\\\", "/");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String getJavaPath() {
|
|
|
|
|
String basePath = getProjectPath();
|
|
|
|
|
public static String getProjectName() {
|
|
|
|
|
return StrUtils.last(getProjectBasePath(), "/");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String getProjectPath(String moduleName) {
|
|
|
|
|
String projectBasePath = getProjectBasePath();
|
|
|
|
|
if (!isMultiModule()) {
|
|
|
|
|
return projectBasePath;
|
|
|
|
|
} else {
|
|
|
|
|
return projectBasePath + "/" + getProjectName() + "-" + moduleName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static boolean isMultiModule() {
|
|
|
|
|
return CONFIG.getBoolean(CfgConsts.MODULE_MULTIPLE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String getJavaPath(String moduleName) {
|
|
|
|
|
String basePath = getProjectPath(moduleName);
|
|
|
|
|
String configPath = CONFIG.getString(CfgConsts.PROJECT_PATH_JAVA);
|
|
|
|
|
String defaultPath = CfgConsts.DEFAULT_PROJECT_PATH_JAVA;
|
|
|
|
|
String path = StrUtils.defaultIfBlank(configPath, defaultPath);
|
|
|
|
@ -27,10 +44,10 @@ public class PathUtils {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String getPackageBasePath(String moduleName) {
|
|
|
|
|
String basePath = getJavaPath();
|
|
|
|
|
String javaPath = getJavaPath(moduleName);
|
|
|
|
|
String packageName = CONFIG.getString(CfgConsts.PACKAGE_NAME_BASE);
|
|
|
|
|
String path = packageToPath(packageName);
|
|
|
|
|
return Paths.get(basePath, moduleName, path).toString();
|
|
|
|
|
String packagePath = packageToPath(packageName);
|
|
|
|
|
return Paths.get(javaPath, packagePath, moduleName).toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String getPathBasedPackage(
|
|
|
|
@ -42,15 +59,9 @@ public class PathUtils {
|
|
|
|
|
return Paths.get(basePath, path).toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static boolean isMultiModule() {
|
|
|
|
|
return CONFIG.getBoolean(CfgConsts.MODULE_MULTIPLE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String getModuleName(String configName, String defaultName) {
|
|
|
|
|
if (!isMultiModule()) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
return StrUtils.defaultIfBlank(configName, defaultName);
|
|
|
|
|
public static String getModuleName(String configModuleName, String defaultModuleName) {
|
|
|
|
|
return isMultiModule() ? StrUtils.defaultIfBlank(configModuleName, defaultModuleName) : "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String getRepositoryModuleName() {
|
|
|
|
@ -71,54 +82,53 @@ public class PathUtils {
|
|
|
|
|
return getModuleName(configName, defaultName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static String getServicePackagePath() {
|
|
|
|
|
String moduleName = getServiceModuleName();
|
|
|
|
|
String configPath = CONFIG.getString(CfgConsts.PACKAGE_NAME_SERVICE);
|
|
|
|
|
String defaultPath = CfgConsts.DEFAULT_PACKAGE_NAME_MAPPER;
|
|
|
|
|
return getPathBasedPackage(moduleName, configPath, defaultPath);
|
|
|
|
|
String configName = CONFIG.getString(CfgConsts.PACKAGE_NAME_SERVICE);
|
|
|
|
|
String defaultName = CfgConsts.DEFAULT_PACKAGE_NAME_MAPPER;
|
|
|
|
|
return getPathBasedPackage(moduleName, configName, defaultName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String getControllerPackagePath() {
|
|
|
|
|
String moduleName = getControllerModuleName();
|
|
|
|
|
String configPath = CONFIG.getString(CfgConsts.PACKAGE_NAME_CONTROLLER);
|
|
|
|
|
String defaultPath = CfgConsts.DEFAULT_PACKAGE_NAME_CONTROLLER;
|
|
|
|
|
return getPathBasedPackage(moduleName, configPath, defaultPath);
|
|
|
|
|
String configName = CONFIG.getString(CfgConsts.PACKAGE_NAME_CONTROLLER);
|
|
|
|
|
String defaultName = CfgConsts.DEFAULT_PACKAGE_NAME_CONTROLLER;
|
|
|
|
|
return getPathBasedPackage(moduleName, configName, defaultName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String getViewPackagePath() {
|
|
|
|
|
String moduleName = getControllerModuleName();
|
|
|
|
|
String configPath = CONFIG.getString(CfgConsts.PACKAGE_NAME_VIEW);
|
|
|
|
|
String defaultPath = CfgConsts.DEFAULT_PACKAGE_NAME_VIEW;
|
|
|
|
|
return getPathBasedPackage(moduleName, configPath, defaultPath);
|
|
|
|
|
String configName = CONFIG.getString(CfgConsts.PACKAGE_NAME_VIEW);
|
|
|
|
|
String defaultName = CfgConsts.DEFAULT_PACKAGE_NAME_VIEW;
|
|
|
|
|
return getPathBasedPackage(moduleName, configName, defaultName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String getFormPackagePath() {
|
|
|
|
|
String moduleName = getControllerModuleName();
|
|
|
|
|
String configPath = CONFIG.getString(CfgConsts.PACKAGE_NAME_FORM);
|
|
|
|
|
String defaultPath = CfgConsts.DEFAULT_PACKAGE_NAME_FORM;
|
|
|
|
|
return getPathBasedPackage(moduleName, configPath, defaultPath);
|
|
|
|
|
String configName = CONFIG.getString(CfgConsts.PACKAGE_NAME_FORM);
|
|
|
|
|
String defaultName = CfgConsts.DEFAULT_PACKAGE_NAME_FORM;
|
|
|
|
|
return getPathBasedPackage(moduleName, configName, defaultName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String getQueryPackagePath() {
|
|
|
|
|
String moduleName = getControllerModuleName();
|
|
|
|
|
String configPath = CONFIG.getString(CfgConsts.PACKAGE_NAME_QUERY);
|
|
|
|
|
String defaultPath = CfgConsts.DEFAULT_PACKAGE_NAME_QUERY;
|
|
|
|
|
return getPathBasedPackage(moduleName, configPath, defaultPath);
|
|
|
|
|
String configName = CONFIG.getString(CfgConsts.PACKAGE_NAME_QUERY);
|
|
|
|
|
String defaultName = CfgConsts.DEFAULT_PACKAGE_NAME_QUERY;
|
|
|
|
|
return getPathBasedPackage(moduleName, configName, defaultName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String getPoPackagePath() {
|
|
|
|
|
String moduleName = getRepositoryModuleName();
|
|
|
|
|
String configPath = CONFIG.getString(CfgConsts.PACKAGE_NAME_PO);
|
|
|
|
|
String defaultPath = CfgConsts.DEFAULT_PACKAGE_NAME_PO;
|
|
|
|
|
return getPathBasedPackage(moduleName, configPath, defaultPath);
|
|
|
|
|
String configName = CONFIG.getString(CfgConsts.PACKAGE_NAME_PO);
|
|
|
|
|
String defaultName = CfgConsts.DEFAULT_PACKAGE_NAME_PO;
|
|
|
|
|
return getPathBasedPackage(moduleName, configName, defaultName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String getMapperPackagePath() {
|
|
|
|
|
String moduleName = getRepositoryModuleName();
|
|
|
|
|
String configPath = CONFIG.getString(CfgConsts.PACKAGE_NAME_MAPPER);
|
|
|
|
|
String defaultPath = CfgConsts.DEFAULT_PACKAGE_NAME_MAPPER;
|
|
|
|
|
return getPathBasedPackage(moduleName, configPath, defaultPath);
|
|
|
|
|
String configName = CONFIG.getString(CfgConsts.PACKAGE_NAME_MAPPER);
|
|
|
|
|
String defaultName = CfgConsts.DEFAULT_PACKAGE_NAME_MAPPER;
|
|
|
|
|
return getPathBasedPackage(moduleName, configName, defaultName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static String getFilename(String className, String suffix) {
|
|
|
|
|