|
|
|
@ -21,6 +21,7 @@ import groovy.lang.GroovyClassLoader;
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.net.URI;
|
|
|
|
|
import java.net.URL;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
@ -46,22 +47,24 @@ public class AetherGrapeEngineTests {
|
|
|
|
|
|
|
|
|
|
private final GroovyClassLoader groovyClassLoader = new GroovyClassLoader();
|
|
|
|
|
|
|
|
|
|
private final AetherGrapeEngine grapeEngine = createGrapeEngine();
|
|
|
|
|
|
|
|
|
|
private AetherGrapeEngine createGrapeEngine() {
|
|
|
|
|
return AetherGrapeEngineFactory.create(this.groovyClassLoader, Arrays
|
|
|
|
|
.asList(new RepositoryConfiguration("central", URI
|
|
|
|
|
.create("http://repo1.maven.org/maven2"), false),
|
|
|
|
|
new RepositoryConfiguration("spring-milestone", URI
|
|
|
|
|
.create("http://repo.spring.io/milestone"), false)),
|
|
|
|
|
new DependencyResolutionContext());
|
|
|
|
|
private final RepositoryConfiguration springMilestones = new RepositoryConfiguration(
|
|
|
|
|
"spring-milestones", URI.create("https://repo.spring.io/milestone"), false);
|
|
|
|
|
|
|
|
|
|
private AetherGrapeEngine createGrapeEngine(
|
|
|
|
|
RepositoryConfiguration... additionalRepositories) {
|
|
|
|
|
List<RepositoryConfiguration> repositoryConfigurations = new ArrayList<RepositoryConfiguration>();
|
|
|
|
|
repositoryConfigurations.add(new RepositoryConfiguration("central", URI
|
|
|
|
|
.create("http://repo1.maven.org/maven2"), false));
|
|
|
|
|
repositoryConfigurations.addAll(Arrays.asList(additionalRepositories));
|
|
|
|
|
return AetherGrapeEngineFactory.create(this.groovyClassLoader,
|
|
|
|
|
repositoryConfigurations, new DependencyResolutionContext());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void dependencyResolution() {
|
|
|
|
|
Map<String, Object> args = new HashMap<String, Object>();
|
|
|
|
|
|
|
|
|
|
this.grapeEngine.grab(args,
|
|
|
|
|
createGrapeEngine(this.springMilestones).grab(args,
|
|
|
|
|
createDependency("org.springframework", "spring-jdbc", "3.2.4.RELEASE"));
|
|
|
|
|
|
|
|
|
|
assertEquals(5, this.groovyClassLoader.getURLs().length);
|
|
|
|
@ -94,7 +97,7 @@ public class AetherGrapeEngineTests {
|
|
|
|
|
|
|
|
|
|
List<RemoteRepository> repositories = (List<RemoteRepository>) ReflectionTestUtils
|
|
|
|
|
.getField(grapeEngine, "repositories");
|
|
|
|
|
assertEquals(2, repositories.size());
|
|
|
|
|
assertEquals(1, repositories.size());
|
|
|
|
|
assertEquals("central-mirror", repositories.get(0).getId());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
@ -111,7 +114,7 @@ public class AetherGrapeEngineTests {
|
|
|
|
|
|
|
|
|
|
List<RemoteRepository> repositories = (List<RemoteRepository>) ReflectionTestUtils
|
|
|
|
|
.getField(grapeEngine, "repositories");
|
|
|
|
|
assertEquals(2, repositories.size());
|
|
|
|
|
assertEquals(1, repositories.size());
|
|
|
|
|
Authentication authentication = repositories.get(0).getAuthentication();
|
|
|
|
|
assertNotNull(authentication);
|
|
|
|
|
}
|
|
|
|
@ -125,7 +128,7 @@ public class AetherGrapeEngineTests {
|
|
|
|
|
args.put("excludes",
|
|
|
|
|
Arrays.asList(createExclusion("org.springframework", "spring-core")));
|
|
|
|
|
|
|
|
|
|
this.grapeEngine.grab(args,
|
|
|
|
|
createGrapeEngine(this.springMilestones).grab(args,
|
|
|
|
|
createDependency("org.springframework", "spring-jdbc", "3.2.4.RELEASE"),
|
|
|
|
|
createDependency("org.springframework", "spring-beans", "3.2.4.RELEASE"));
|
|
|
|
|
|
|
|
|
@ -136,7 +139,7 @@ public class AetherGrapeEngineTests {
|
|
|
|
|
public void nonTransitiveDependencyResolution() {
|
|
|
|
|
Map<String, Object> args = new HashMap<String, Object>();
|
|
|
|
|
|
|
|
|
|
this.grapeEngine.grab(
|
|
|
|
|
createGrapeEngine().grab(
|
|
|
|
|
args,
|
|
|
|
|
createDependency("org.springframework", "spring-jdbc", "3.2.4.RELEASE",
|
|
|
|
|
false));
|
|
|
|
@ -150,7 +153,7 @@ public class AetherGrapeEngineTests {
|
|
|
|
|
GroovyClassLoader customClassLoader = new GroovyClassLoader();
|
|
|
|
|
args.put("classLoader", customClassLoader);
|
|
|
|
|
|
|
|
|
|
this.grapeEngine.grab(args,
|
|
|
|
|
createGrapeEngine(this.springMilestones).grab(args,
|
|
|
|
|
createDependency("org.springframework", "spring-jdbc", "3.2.4.RELEASE"));
|
|
|
|
|
|
|
|
|
|
assertEquals(0, this.groovyClassLoader.getURLs().length);
|
|
|
|
@ -160,10 +163,10 @@ 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"));
|
|
|
|
|
AetherGrapeEngine grapeEngine = this.createGrapeEngine();
|
|
|
|
|
grapeEngine
|
|
|
|
|
.addResolver(createResolver("restlet.org", "http://maven.restlet.org"));
|
|
|
|
|
grapeEngine.grab(args, createDependency("org.restlet", "org.restlet", "1.1.6"));
|
|
|
|
|
assertEquals(1, this.groovyClassLoader.getURLs().length);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -173,7 +176,7 @@ public class AetherGrapeEngineTests {
|
|
|
|
|
"grails-dependencies", "2.4.0");
|
|
|
|
|
dependency.put("type", "foo");
|
|
|
|
|
dependency.put("ext", "bar");
|
|
|
|
|
this.grapeEngine.grab(Collections.emptyMap(), dependency);
|
|
|
|
|
createGrapeEngine().grab(Collections.emptyMap(), dependency);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@ -182,7 +185,7 @@ public class AetherGrapeEngineTests {
|
|
|
|
|
Map<String, Object> dependency = createDependency("org.springframework",
|
|
|
|
|
"spring-framework-bom", "4.0.5.RELEASE");
|
|
|
|
|
dependency.put("type", "pom");
|
|
|
|
|
this.grapeEngine.grab(args, dependency);
|
|
|
|
|
createGrapeEngine().grab(args, dependency);
|
|
|
|
|
URL[] urls = this.groovyClassLoader.getURLs();
|
|
|
|
|
assertEquals(1, urls.length);
|
|
|
|
|
assertTrue(urls[0].toExternalForm().endsWith(".pom"));
|
|
|
|
@ -194,7 +197,7 @@ public class AetherGrapeEngineTests {
|
|
|
|
|
Map<String, Object> dependency = createDependency("org.springframework",
|
|
|
|
|
"spring-framework-bom", "4.0.5.RELEASE");
|
|
|
|
|
dependency.put("ext", "pom");
|
|
|
|
|
this.grapeEngine.grab(args, dependency);
|
|
|
|
|
createGrapeEngine().grab(args, dependency);
|
|
|
|
|
URL[] urls = this.groovyClassLoader.getURLs();
|
|
|
|
|
assertEquals(1, urls.length);
|
|
|
|
|
assertTrue(urls[0].toExternalForm().endsWith(".pom"));
|
|
|
|
@ -207,7 +210,7 @@ public class AetherGrapeEngineTests {
|
|
|
|
|
Map<String, Object> dependency = createDependency("org.springframework",
|
|
|
|
|
"spring-jdbc", "3.2.4.RELEASE", false);
|
|
|
|
|
dependency.put("classifier", "sources");
|
|
|
|
|
this.grapeEngine.grab(args, dependency);
|
|
|
|
|
createGrapeEngine().grab(args, dependency);
|
|
|
|
|
|
|
|
|
|
URL[] urls = this.groovyClassLoader.getURLs();
|
|
|
|
|
assertEquals(1, urls.length);
|
|
|
|
|