Make local repo configurable
This commit is contained in:
committed by
Mark Fisher
parent
6e23336087
commit
50ff27b7c8
@@ -34,6 +34,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
* public {@link #launch(String[])} method.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @author Marius Bogoevici
|
||||
*/
|
||||
public class ModuleJarLauncher extends ExecutableArchiveLauncher {
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.springframework.cloud.stream.module.resolver.AetherModuleResolver;
|
||||
import org.springframework.cloud.stream.module.resolver.ModuleResolver;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.FileSystemUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -44,25 +45,30 @@ import org.springframework.util.StringUtils;
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @author Ilayaperumal Gopinathan
|
||||
* @author Marius Bogoevici
|
||||
*/
|
||||
public class ModuleLauncher {
|
||||
|
||||
private static final String LOCAL_REPO = "/opt/spring/modules";
|
||||
// TODO ensure that this properly supports Windows too
|
||||
private static final String DEFAULT_LOCAL_REPO =
|
||||
System.getProperty("user.home") + File.separator + ".m2" + File.separator + "repository";
|
||||
|
||||
private static final String DEFAULT_EXTENSION = "jar";
|
||||
|
||||
private static final String DEFAULT_CLASSIFIER = "exec";
|
||||
|
||||
private static final Pattern COORDINATES_PATTERN = Pattern.compile("([^: ]+):([^: ]+)(:([^: ]*)(:([^: ]+))?)?:([^: ]+)");
|
||||
private static final Pattern COORDINATES_PATTERN =
|
||||
Pattern.compile("([^: ]+):([^: ]+)(:([^: ]*)(:([^: ]+))?)?:([^: ]+)");
|
||||
|
||||
private final ModuleResolver moduleResolver;
|
||||
|
||||
public ModuleLauncher() {
|
||||
this(Collections.singletonMap("spring-cloud-stream-modules", "http://repo.spring.io/spring-cloud-stream-modules"));
|
||||
public ModuleLauncher(String localRepository) {
|
||||
this(localRepository,
|
||||
Collections.singletonMap("spring-cloud-stream-modules", "http://repo.spring.io/spring-cloud-stream-modules"));
|
||||
}
|
||||
|
||||
public ModuleLauncher(Map<String, String> remoteRepositories) {
|
||||
this.moduleResolver = new AetherModuleResolver(new File(LOCAL_REPO), remoteRepositories);
|
||||
public ModuleLauncher(String localRepository, Map<String, String> remoteRepositories) {
|
||||
this.moduleResolver = new AetherModuleResolver(new File(localRepository), remoteRepositories);
|
||||
}
|
||||
|
||||
public void launch(String[] modules, String[] args) {
|
||||
@@ -111,7 +117,15 @@ public class ModuleLauncher {
|
||||
System.err.println("Either the 'modules' system property or 'MODULES' environment variable is required.");
|
||||
System.exit(1);
|
||||
}
|
||||
ModuleLauncher launcher = new ModuleLauncher();
|
||||
|
||||
String localRepository = System.getProperty("local.repository");
|
||||
if (localRepository == null) {
|
||||
localRepository = System.getenv("LOCAL_REPOSITORY");
|
||||
}
|
||||
if (localRepository == null) {
|
||||
localRepository = DEFAULT_LOCAL_REPO;
|
||||
}
|
||||
ModuleLauncher launcher = new ModuleLauncher(localRepository);
|
||||
launcher.launch(modules.split(","), args);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user