diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenPathMacroContributor.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenPathMacroContributor.java index 7a1898c48829..591ed7d10e8a 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenPathMacroContributor.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenPathMacroContributor.java @@ -16,8 +16,8 @@ final class MavenPathMacroContributor implements PathMacroContributor { @Override public void forceRegisterPathMacros(@NotNull Map macros) { - if (System.getProperty(MavenUtil.PROP_FORCED_M2_HOME) != null) { - macros.put(PathMacrosImpl.MAVEN_REPOSITORY, System.getProperty(MavenUtil.PROP_FORCED_M2_HOME)); + if (System.getProperty(MavenUtil.MAVEN_REPO_LOCAL) != null) { + macros.put(PathMacrosImpl.MAVEN_REPOSITORY, System.getProperty(MavenUtil.MAVEN_REPO_LOCAL)); } } } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenUtil.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenUtil.java index 0a9b336aa0ce..29568522c000 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenUtil.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenUtil.java @@ -136,7 +136,10 @@ public class MavenUtil { public static final String LIB_DIR = "lib"; public static final String CLIENT_ARTIFACT_SUFFIX = "-client"; public static final String CLIENT_EXPLODED_ARTIFACT_SUFFIX = CLIENT_ARTIFACT_SUFFIX + " exploded"; - protected static final String PROP_FORCED_M2_HOME = "idea.force.m2.home"; + @Deprecated + private static final String PROP_FORCED_M2_HOME = "idea.force.m2.home"; + public static final String MAVEN_REPO_LOCAL = "maven.repo.local"; + @SuppressWarnings("unchecked") private static final Pair[] SUPER_POM_PATHS = new Pair[]{ @@ -945,11 +948,21 @@ public class MavenUtil { @NotNull public static File resolveDefaultLocalRepository() { + String mavenRepoLocal = System.getProperty(MAVEN_REPO_LOCAL); + + if (mavenRepoLocal != null) { + MavenLog.LOG.info("using " + MAVEN_REPO_LOCAL + "=" + mavenRepoLocal + " as maven home"); + return new File(mavenRepoLocal); + } + String forcedM2Home = System.getProperty(PROP_FORCED_M2_HOME); if (forcedM2Home != null) { + MavenLog.LOG.error(PROP_FORCED_M2_HOME + " is deprecated, use maven.repo.local property instead"); return new File(forcedM2Home); } + File result = doResolveLocalRepository(resolveUserSettingsFile(null), null); + if (result == null) { result = new File(resolveM2Dir(), REPOSITORY_DIR); } @@ -968,10 +981,17 @@ public class MavenUtil { @Nullable String overriddenUserSettingsFile) { String forcedM2Home = System.getProperty(PROP_FORCED_M2_HOME); if (forcedM2Home != null) { + MavenLog.LOG.error(PROP_FORCED_M2_HOME + " is deprecated, use maven.repo.local property instead"); return new File(forcedM2Home); } File result = null; if (!isEmptyOrSpaces(overriddenLocalRepository)) result = new File(overriddenLocalRepository); + + String localRepoHome = System.getProperty(MAVEN_REPO_LOCAL); + if (localRepoHome != null) { + MavenLog.LOG.debug("Using " + MAVEN_REPO_LOCAL + "=" + localRepoHome); + return new File(localRepoHome); + } if (result == null) { result = doResolveLocalRepository(resolveUserSettingsFile(overriddenUserSettingsFile), resolveGlobalSettingsFile(mavenHomeType));