From 70295795347ce264fa0c990cc06f2cd085e6281f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=87=91=E6=88=9F?= Date: Sun, 31 Jan 2021 12:39:58 +0800 Subject: [PATCH] fix intellij gradle build issue with incorrect file protocol syntax --- .../translator/EnablePrivateAccessTranslator.java | 8 ++++---- .../com/alibaba/testable/processor/util/PathUtil.java | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/testable-processor/src/main/java/com/alibaba/testable/processor/translator/EnablePrivateAccessTranslator.java b/testable-processor/src/main/java/com/alibaba/testable/processor/translator/EnablePrivateAccessTranslator.java index ac04ed5..a39d891 100644 --- a/testable-processor/src/main/java/com/alibaba/testable/processor/translator/EnablePrivateAccessTranslator.java +++ b/testable-processor/src/main/java/com/alibaba/testable/processor/translator/EnablePrivateAccessTranslator.java @@ -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 diff --git a/testable-processor/src/main/java/com/alibaba/testable/processor/util/PathUtil.java b/testable-processor/src/main/java/com/alibaba/testable/processor/util/PathUtil.java index 4c9fe9d..9fa97f1 100644 --- a/testable-processor/src/main/java/com/alibaba/testable/processor/util/PathUtil.java +++ b/testable-processor/src/main/java/com/alibaba/testable/processor/util/PathUtil.java @@ -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