String () { String m2home = System.getenv("M2_HOME"); if (isValidMavenHome(m2home)) return m2home; String mavenHome = System.getenv("MAVEN_HOME"); if (isValidMavenHome(mavenHome)) return mavenHome; String m2UserHome = SystemProperties.getUserHome() + File.separator + M2_DIR; if (isValidMavenHome(m2UserHome)) return m2UserHome; if (SystemInfoRt.isMac) { String mavenFromBrew = fromBrew(); if (isValidMavenHome(mavenFromBrew)) return mavenFromBrew; } if (SystemInfoRt.isLinux || SystemInfoRt.isMac) { String defaultHome = "/usr/share/maven"; if (isValidMavenHome(defaultHome)) return defaultHome; } return null; }