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]
This commit is contained in:
Andy Wilkinson 2013-10-24 15:22:50 +01:00
parent 629a77c3e2
commit 4f47f71dc2
3 changed files with 25 additions and 7 deletions

View File

@ -148,12 +148,18 @@ public class AetherGrapeEngine implements GrapeEngine {
this.repositorySystemSession = repositorySystemSession;
this.repositories = Arrays.asList(new RemoteRepository.Builder("central",
"default", "http://repo1.maven.org/maven2/").build(),
new RemoteRepository.Builder("spring-snapshot", "default",
"http://repo.spring.io/snapshot").build(),
new RemoteRepository.Builder("spring-milestone", "default",
"http://repo.spring.io/milestone").build());
List<RemoteRepository> repositories = new ArrayList<RemoteRepository>();
repositories.add(new RemoteRepository.Builder("central", "default",
"http://repo1.maven.org/maven2/").build());
if (!Boolean.getBoolean("disableSpringSnapshotRepos")) {
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
.getService(ArtifactDescriptorReader.class);

View File

@ -70,6 +70,19 @@ public class AetherGrapeEngineTests {
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,
String version) {
Map<String, Object> dependency = new HashMap<String, Object>();

View File

@ -49,7 +49,6 @@ public class SampleIntegrationTests {
@BeforeClass
public static void cleanGrapes() throws Exception {
GrapesCleaner.cleanIfNecessary();
// System.setProperty("ivy.message.logger.level", "3");
}
@Rule