Support comma separated remote repos
- Change `remoteRepository` option to `remoteRepositories` that accepts comma separated string values. - AetherModuleResolver would expect set of remote repositories and create `RemoteRepository` list for the given set. Use String[] for remoteRepositories - This will let spring boot's ConfigurationProperties handle the properties and use the Map<String,String> for remoteProperties in AetherModuleResolver - Generate ID for the map
This commit is contained in:
committed by
Marius Bogoevici
parent
15e3c6066f
commit
4ab01b6e7b
@@ -16,7 +16,8 @@
|
||||
|
||||
package org.springframework.cloud.stream.module.launcher;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
@@ -45,8 +46,12 @@ public class ModuleLauncherConfiguration {
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(ModuleResolver.class)
|
||||
public ModuleResolver moduleResolver() {
|
||||
return new AetherModuleResolver(properties.getLocalRepository(), Collections.singletonMap(
|
||||
"remoteRepository", properties.getRemoteRepository()));
|
||||
int i = 1;
|
||||
Map<String, String> repositoriesMap = new HashMap<>();
|
||||
for (String repository: properties.getRemoteRepositories()) {
|
||||
repositoriesMap.put("repository " + i++, repository);
|
||||
}
|
||||
return new AetherModuleResolver(properties.getLocalRepository(), repositoriesMap);
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -36,16 +36,16 @@ public class ModuleLauncherProperties {
|
||||
+ File.separator + ".m2" + File.separator + "repository");
|
||||
|
||||
/**
|
||||
* Location of a remote maven repository from which modules will be downloaded, if not available locally.
|
||||
* Location of comma separated remote maven repositories from which modules will be downloaded, if not available locally.
|
||||
*/
|
||||
private String remoteRepository = "https://repo.spring.io/libs-snapshot";
|
||||
private String[] remoteRepositories = new String[] {"https://repo.spring.io/libs-snapshot"};
|
||||
|
||||
public void setRemoteRepository(String remoteRepository) {
|
||||
this.remoteRepository = remoteRepository;
|
||||
public void setRemoteRepositories(String[] remoteRepositories) {
|
||||
this.remoteRepositories = remoteRepositories;
|
||||
}
|
||||
|
||||
protected String getRemoteRepository() {
|
||||
return remoteRepository;
|
||||
protected String[] getRemoteRepositories() {
|
||||
return remoteRepositories;
|
||||
}
|
||||
|
||||
public void setLocalRepository(File localRepository) {
|
||||
|
||||
@@ -118,7 +118,7 @@ public class AetherModuleResolver implements ModuleResolver {
|
||||
classifier = "";
|
||||
}
|
||||
Assert.hasText(version, "'version' cannot be blank.");
|
||||
|
||||
|
||||
Artifact artifact = new DefaultArtifact(groupId, artifactId, classifier, extension, version);
|
||||
RepositorySystemSession session = newRepositorySystemSession(repositorySystem,
|
||||
localRepository.getAbsolutePath());
|
||||
|
||||
@@ -15,12 +15,18 @@
|
||||
|
||||
package org.springframework.cloud.stream.module.resolver;
|
||||
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.get;
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.github.tomakehurst.wiremock.junit.WireMockRule;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -29,12 +35,7 @@ import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.util.SocketUtils;
|
||||
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.get;
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import com.github.tomakehurst.wiremock.junit.WireMockRule;
|
||||
|
||||
/**
|
||||
* @author David Turanski
|
||||
@@ -72,7 +73,7 @@ public class AetherModuleResolverTests {
|
||||
Map<String, String> remoteRepos = new HashMap<>();
|
||||
remoteRepos.put("modules", "http://repo.spring.io/spring-cloud-stream-modules");
|
||||
AetherModuleResolver defaultModuleResolver = new AetherModuleResolver(localRepository, remoteRepos);
|
||||
Resource resource = defaultModuleResolver.resolve("org.springframework.cloud.stream.module", "time-source",
|
||||
Resource resource = defaultModuleResolver.resolve("org.springframework.cloud.stream.module", "time-source",
|
||||
"1.0.0.BUILD-SNAPSHOT", "exec", "jar");
|
||||
assertTrue(resource.exists());
|
||||
assertEquals(resource.getFile().getName(), "time-source-1.0.0.BUILD-SNAPSHOT-exec.jar");
|
||||
|
||||
Reference in New Issue
Block a user