Determine deployable app version dynamically

The deployer now checks its own version and uses that to set
up the app versions via "launcher.version" on the command line.

Closes gh-16
This commit is contained in:
Dave Syer
2016-08-15 17:05:52 +01:00
parent 7b6d0d65f1
commit 15a2a83fb0
2 changed files with 9 additions and 2 deletions

View File

@@ -62,6 +62,8 @@ public class DeployerThread extends Thread {
private static final Logger logger = LoggerFactory.getLogger(DeployerThread.class);
private static final String DEFAULT_VERSION = "1.2.0.BUILD-SNAPSHOT";
private Map<String, DeploymentState> deployed = new ConcurrentHashMap<>();
private String[] args;
@@ -169,12 +171,17 @@ public class DeployerThread extends Thread {
return null;
}
private String getVersion() {
Package pkg = DeployerThread.class.getPackage();
return (pkg != null ? pkg.getImplementationVersion() : DEFAULT_VERSION);
}
private void launch() {
final ConfigurableApplicationContext context = new SpringApplicationBuilder(
PropertyPlaceholderAutoConfiguration.class, DeployerConfiguration.class)
.web(false).properties("spring.config.name=cloud",
"banner.location=launcher-banner.txt")
"banner.location=launcher-banner.txt", "launcher.version="+getVersion())
.run(this.args);
final AppDeployer deployer = context.getBean(AppDeployer.class);

View File

@@ -1,6 +1,6 @@
dt:
pre: maven://org.springframework.cloud.launcher:spring-cloud-launcher-
ver: 1.2.0.BUILD-SNAPSHOT
ver: ${launcher.version}
spring:
cloud:
launcher: