Attempt to allow Aether to load from local repo

This commit is contained in:
Dave Syer 2013-11-07 15:46:17 +00:00
parent e46c427b75
commit 578fadf6f9

View File

@ -114,11 +114,24 @@ public class AetherGrapeEngine implements GrapeEngine {
if (StringUtils.hasLength(grapeRoot)) { if (StringUtils.hasLength(grapeRoot)) {
return new File(grapeRoot); return new File(grapeRoot);
} }
return getDefaultM2HomeDirectory();
}
private File getDefaultM2HomeDirectory() {
String mavenRoot = System.getProperty("maven.home");
if (StringUtils.hasLength(mavenRoot)) {
return new File(mavenRoot);
}
return new File(System.getProperty("user.home"), ".m2"); return new File(System.getProperty("user.home"), ".m2");
} }
private Set<RemoteRepository> getRemoteRepositories() { private Set<RemoteRepository> getRemoteRepositories() {
LinkedHashSet<RemoteRepository> repositories = new LinkedHashSet<RemoteRepository>(); LinkedHashSet<RemoteRepository> repositories = new LinkedHashSet<RemoteRepository>();
String grapeRoot = System.getProperty("grape.root");
if (StringUtils.hasLength(grapeRoot)) {
addRemoteRepository(repositories, "local", new File(
getDefaultM2HomeDirectory(), "repository").toURI().toASCIIString());
}
addRemoteRepository(repositories, "central", "http://repo1.maven.org/maven2/"); addRemoteRepository(repositories, "central", "http://repo1.maven.org/maven2/");
return repositories; return repositories;
} }