diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngine.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngine.java index 212b8b5d27..7fb1d56ecc 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngine.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngine.java @@ -216,6 +216,14 @@ public class AetherGrapeEngine implements GrapeEngine { return files; } + @Override + public void addResolver(Map args) { + String name = (String) args.get("name"); + String root = (String) args.get("root"); + + addRemoteRepository(this.repositories, name, root); + } + @Override public Map>> enumerateGrapes() { throw new UnsupportedOperationException("Grape enumeration is not supported"); @@ -236,11 +244,6 @@ public class AetherGrapeEngine implements GrapeEngine { throw new UnsupportedOperationException("Listing dependencies is not supported"); } - @Override - public void addResolver(Map args) { - throw new UnsupportedOperationException("Adding a resolver is not supported"); - } - @Override public Object grab(String endorsedModule) { throw new UnsupportedOperationException( diff --git a/spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngineTests.java b/spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngineTests.java index 0403afda20..76f47ac4dd 100644 --- a/spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngineTests.java +++ b/spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngineTests.java @@ -85,6 +85,16 @@ public class AetherGrapeEngineTests { } } + @Test + public void resolutionWithCustomResolver() { + Map args = new HashMap(); + 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 createDependency(String group, String module, String version) { Map dependency = new HashMap(); @@ -100,4 +110,11 @@ public class AetherGrapeEngineTests { dependency.put("transitive", transitive); return dependency; } + + private Map createResolver(String name, String url) { + Map resolver = new HashMap(); + resolver.put("name", name); + resolver.put("root", url); + return resolver; + } }