fix intellij gradle build issue with incorrect file protocol syntax

This commit is contained in:
金戟 2021-01-31 12:39:58 +08:00
parent ba951ce744
commit 7029579534
2 changed files with 5 additions and 5 deletions

View File

@ -171,18 +171,18 @@ public class EnablePrivateAccessTranslator extends BaseTranslator {
cls = Class.forName(sourceClassFullName);
} catch (ClassNotFoundException e) {
if (System.getProperty(IDEA_PATHS_SELECTOR) != null) {
// fit for intellij 2020.3+
// fit for intellij build
String sourceFileWrapperString = clazz.sourcefile.toString();
String sourceFilePath = sourceFileWrapperString.substring(
sourceFileWrapperString.lastIndexOf("[") + 1, sourceFileWrapperString.indexOf("]"));
int indexOfSrc = sourceFilePath.lastIndexOf(File.separator + "src" + File.separator);
String basePath = sourceFilePath.substring(0, indexOfSrc);
String targetFolderPath = PathUtil.fitPathString(basePath + MAVEN_CLASS_FOLDER);
try {
String targetFolderPath = PathUtil.fitPathString(basePath + MAVEN_CLASS_FOLDER);
cls = loadClass(targetFolderPath, sourceClassFullName);
} catch (ClassNotFoundException e2) {
targetFolderPath = PathUtil.fitPathString(basePath + GRADLE_CLASS_FOLDER);
cls = loadClass(targetFolderPath, sourceClassFullName);
String buildFolderPath = PathUtil.fitPathString(basePath + GRADLE_CLASS_FOLDER);
cls = loadClass(buildFolderPath, sourceClassFullName);
}
} else {
// fit for gradle build

View File

@ -6,7 +6,7 @@ public class PathUtil {
private static final String PROPERTY_OS_NAME = "os.name";
private static final String PATH_SPLIT_UNIX = "/";
private static final String PATH_SPLIT_WIN = "\\\\";
private static final String PROTOCOL_FILE = "file:/";
private static final String PROTOCOL_FILE = "file:";
/**
* Fit path according to operation system type