Add support for @GrabExclude to AetherGrapeEngine

@GrabExclude can now be used to exclude certain transitive dependencies.
In Aether (Maven), exclusions are applied to an individual dependency
rather than being global. In Grape, exclusions are global.
AetherGrapeEngine adheres to the Grape convention by applying every
exclusion create by @GrabExclude to every dependency, effectively making
them global.
This commit is contained in:
Andy Wilkinson
2013-11-06 14:24:58 +00:00
parent 8922a6be4a
commit dc4bf01e95
2 changed files with 55 additions and 9 deletions

View File

@@ -18,6 +18,7 @@ package org.springframework.boot.cli.compiler.grape;
import groovy.lang.GroovyClassLoader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
@@ -47,6 +48,20 @@ public class AetherGrapeEngineTests {
assertEquals(6, this.groovyClassLoader.getURLs().length);
}
@SuppressWarnings("unchecked")
@Test
public void dependencyResolutionWithExclusions() {
Map<String, Object> args = new HashMap<String, Object>();
args.put("excludes",
Arrays.asList(createExclusion("org.springframework", "spring-core")));
this.grapeEngine.grab(args,
createDependency("org.springframework", "spring-jdbc", "3.2.4.RELEASE"),
createDependency("org.springframework", "spring-beans", "3.2.4.RELEASE"));
assertEquals(4, this.groovyClassLoader.getURLs().length);
}
@Test
public void nonTransitiveDependencyResolution() {
Map<String, Object> args = new HashMap<String, Object>();
@@ -117,4 +132,11 @@ public class AetherGrapeEngineTests {
resolver.put("root", url);
return resolver;
}
private Map<String, Object> createExclusion(String group, String module) {
Map<String, Object> exclusion = new HashMap<String, Object>();
exclusion.put("group", group);
exclusion.put("module", module);
return exclusion;
}
}