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:
@@ -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));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user