List<MavenHomeType> () { List<MavenHomeType> result = new ArrayList<>(); String m2home = System.getenv(ENV_M2_HOME); if (!isEmptyOrSpaces(m2home)) { final File homeFromEnv = new File(m2home); if (isValidMavenHome(homeFromEnv)) { result.add(new MavenInSpecificPath(m2home)); } } String mavenHome = System.getenv("MAVEN_HOME"); if (!isEmptyOrSpaces(mavenHome)) { final File mavenHomeFile = new File(mavenHome); if (isValidMavenHome(mavenHomeFile)) { result.add(new MavenInSpecificPath(mavenHome)); } } String userHome = SystemProperties.getUserHome(); if (!isEmptyOrSpaces(userHome)) { final File underUserHome = new File(userHome, M2_DIR); if (isValidMavenHome(underUserHome)) { result.add(new MavenInSpecificPath(userHome)); } } if (SystemInfo.isMac) { File home = fromBrew(); if (home != null) { result.add(new MavenInSpecificPath(home.getAbsolutePath())); } if ((home = fromMacSystemJavaTools()) != null) { result.add(new MavenInSpecificPath(home.getAbsolutePath())); } } else if (SystemInfo.isLinux) { File home = new File("/usr/share/maven"); if (isValidMavenHome(home)) { result.add(new MavenInSpecificPath(home.getAbsolutePath())); } home = new File("/usr/share/maven2"); if (isValidMavenHome(home)) { result.add(new MavenInSpecificPath(home.getAbsolutePath())); } } result.add(BundledMaven3.INSTANCE); return result; }