Update AetherGrapeEngine to honour --local

When running an application, --local can be used to collect the
application's dependencies in a local directory. Prior to
AetherGrapeEngine being introduced, using --local would result in the
dependencies being written to ./grapes. When AetherGrapeEngine was
introduced --local no longer had any effect.

This commit updates AetherGrapeEngine so that it honours --local,
writing its dependencies to ./repository. When --local is not specified
dependencies are written to ~/.m2/repository (the standard location
for the local Maven cache). As part of this change TestCommand has
been refactored so that it lazily initialises its GroovyCompiler. This
ensures that RunCommand has a chance to set the system property that
backs --local before AetherGrapeEngine is initialised and accesses the
property.

Fixes #99
This commit is contained in:
Andy Wilkinson
2013-11-04 11:01:52 +00:00
parent e741557a38
commit b631c113ba
3 changed files with 19 additions and 23 deletions

View File

@@ -141,8 +141,18 @@ public class AetherGrapeEngine implements GrapeEngine {
}
});
LocalRepository localRepo = new LocalRepository(new File(
System.getProperty("user.home"), ".m2/repository"));
String grapeRootProperty = System.getProperty("grape.root");
File root;
if (grapeRootProperty != null && grapeRootProperty.trim().length() > 0) {
root = new File(grapeRootProperty);
}
else {
root = new File(System.getProperty("user.home"), ".m2");
}
LocalRepository localRepo = new LocalRepository(new File(root, "repository"));
repositorySystemSession.setLocalRepositoryManager(this.repositorySystem
.newLocalRepositoryManager(repositorySystemSession, localRepo));