Add support for @GrabResolver to AetherGrapeEngine
@GrabResolver can now be used to add a repository to the list that is used for dependency resolution. Any repository that is added via the annotation will then be available for the lifetime of the AetherGrapeEngine instance. In reality, this equates to the lifetime of the Boot application. This is in keeping with the documented default behaviour [1]: "By default, the grape subsystem is shared globally, so added resolvers will become available for any subsequent grab calls". [1] - http://groovy.codehaus.org/api/groovy/lang/GrabResolver.html [bs-345] [60145036]
This commit is contained in:
@@ -85,6 +85,16 @@ public class AetherGrapeEngineTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolutionWithCustomResolver() {
|
||||
Map<String, Object> args = new HashMap<String, Object>();
|
||||
this.grapeEngine.addResolver(createResolver("restlet.org",
|
||||
"http://maven.restlet.org"));
|
||||
this.grapeEngine.grab(args,
|
||||
createDependency("org.restlet", "org.restlet", "1.1.6"));
|
||||
assertEquals(1, this.groovyClassLoader.getURLs().length);
|
||||
}
|
||||
|
||||
private Map<String, Object> createDependency(String group, String module,
|
||||
String version) {
|
||||
Map<String, Object> dependency = new HashMap<String, Object>();
|
||||
@@ -100,4 +110,11 @@ public class AetherGrapeEngineTests {
|
||||
dependency.put("transitive", transitive);
|
||||
return dependency;
|
||||
}
|
||||
|
||||
private Map<String, Object> createResolver(String name, String url) {
|
||||
Map<String, Object> resolver = new HashMap<String, Object>();
|
||||
resolver.put("name", name);
|
||||
resolver.put("root", url);
|
||||
return resolver;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user