Commit 4f47f71d authored by Andy Wilkinson's avatar Andy Wilkinson

Allow use of snapshot repos to be disabled

Previously, the Ivy-based Grape engine used a system property,
disableSpringSnapshotRepos, to control whether or not Spring's
snapshot and milestone repositories were used for dependency
resolution. This commit adds the same capability to AetherGrapeEngine.

[#59489826]
parent 629a77c3
...@@ -148,12 +148,18 @@ public class AetherGrapeEngine implements GrapeEngine { ...@@ -148,12 +148,18 @@ public class AetherGrapeEngine implements GrapeEngine {
this.repositorySystemSession = repositorySystemSession; this.repositorySystemSession = repositorySystemSession;
this.repositories = Arrays.asList(new RemoteRepository.Builder("central", List<RemoteRepository> repositories = new ArrayList<RemoteRepository>();
"default", "http://repo1.maven.org/maven2/").build(), repositories.add(new RemoteRepository.Builder("central", "default",
new RemoteRepository.Builder("spring-snapshot", "default", "http://repo1.maven.org/maven2/").build());
"http://repo.spring.io/snapshot").build(),
new RemoteRepository.Builder("spring-milestone", "default", if (!Boolean.getBoolean("disableSpringSnapshotRepos")) {
"http://repo.spring.io/milestone").build()); repositories.add(new RemoteRepository.Builder("spring-snapshot", "default",
"http://repo.spring.io/snapshot").build());
repositories.add(new RemoteRepository.Builder("spring-milestone", "default",
"http://repo.spring.io/milestone").build());
}
this.repositories = repositories;
this.artifactDescriptorReader = mavenServiceLocator this.artifactDescriptorReader = mavenServiceLocator
.getService(ArtifactDescriptorReader.class); .getService(ArtifactDescriptorReader.class);
......
...@@ -70,6 +70,19 @@ public class AetherGrapeEngineTests { ...@@ -70,6 +70,19 @@ public class AetherGrapeEngineTests {
assertEquals(6, customClassLoader.getURLs().length); assertEquals(6, customClassLoader.getURLs().length);
} }
@Test(expected = DependencyResolutionFailedException.class)
public void resolutionWithSnapshotRepositoriesDisabled() {
Map<String, Object> args = new HashMap<String, Object>();
System.setProperty("disableSpringSnapshotRepos", "true");
try {
new AetherGrapeEngine(this.groovyClassLoader, null, null, null).grab(args,
createDependency("org.springframework", "spring-jdbc", "3.2.0.M1"));
}
finally {
System.clearProperty("disableSpringSnapshotRepos");
}
}
private Map<String, Object> createDependency(String group, String module, private Map<String, Object> createDependency(String group, String module,
String version) { String version) {
Map<String, Object> dependency = new HashMap<String, Object>(); Map<String, Object> dependency = new HashMap<String, Object>();
......
...@@ -49,7 +49,6 @@ public class SampleIntegrationTests { ...@@ -49,7 +49,6 @@ public class SampleIntegrationTests {
@BeforeClass @BeforeClass
public static void cleanGrapes() throws Exception { public static void cleanGrapes() throws Exception {
GrapesCleaner.cleanIfNecessary(); GrapesCleaner.cleanIfNecessary();
// System.setProperty("ivy.message.logger.level", "3");
} }
@Rule @Rule
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment