Merge branch '2.2.x'
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<maven.version>3.5.4</maven.version>
|
||||
<maven.version>3.6.3</maven.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
@@ -55,7 +55,8 @@
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-utils</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<!-- Compatible with Maven -->
|
||||
<version>3.2.1</version>
|
||||
</dependency>
|
||||
<!-- FIXME: 3.0.0 missing classes running tests -->
|
||||
<!--<dependency>
|
||||
|
||||
@@ -51,7 +51,7 @@ public class LauncherCommand extends OptionParsingCommand {
|
||||
|
||||
public static final Log log = LogFactory.getLog(LauncherCommand.class);
|
||||
|
||||
private static final String DEFAULT_VERSION = "2.2.0.BUILD-SNAPSHOT";
|
||||
private static final String DEFAULT_VERSION = "2.2.0.RELEASE";
|
||||
|
||||
private static final Collection<HelpExample> EXAMPLES = new ArrayList<>();
|
||||
|
||||
|
||||
@@ -92,6 +92,12 @@
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
|
||||
package org.springframework.cloud.launcher.deployer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@@ -31,7 +34,10 @@ import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.logging.LogLevel;
|
||||
import org.springframework.boot.logging.logback.LogbackLoggingSystem;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
import org.springframework.util.StreamUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -42,8 +48,6 @@ public class DeployerApplication {
|
||||
private static final Logger logger = LoggerFactory
|
||||
.getLogger(DeployerApplication.class);
|
||||
|
||||
private static final String DEFAULT_VERSION = "2.2.0.BUILD-SNAPSHOT";
|
||||
|
||||
private String[] args;
|
||||
|
||||
public DeployerApplication(String... args) {
|
||||
@@ -103,8 +107,19 @@ public class DeployerApplication {
|
||||
|
||||
String getVersion() {
|
||||
Package pkg = DeployerApplication.class.getPackage();
|
||||
return (pkg != null ? pkg.getImplementationVersion() == null ? DEFAULT_VERSION
|
||||
: pkg.getImplementationVersion() : DEFAULT_VERSION);
|
||||
return (pkg != null ? pkg.getImplementationVersion() == null ? getDefaultVersion()
|
||||
: pkg.getImplementationVersion() : getDefaultVersion());
|
||||
}
|
||||
|
||||
String getDefaultVersion() {
|
||||
try (InputStream in = new ClassPathResource("META-INF/cli-version.txt").getInputStream()) {
|
||||
return StreamUtils.copyToString(in, StandardCharsets.UTF_8);
|
||||
}
|
||||
catch (IOException e) {
|
||||
ReflectionUtils.rethrowRuntimeException(e);
|
||||
}
|
||||
// not reachable since exception rethrown at runtime
|
||||
return null;
|
||||
}
|
||||
|
||||
private void launch() {
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
@project.version@
|
||||
@@ -22,8 +22,7 @@ import org.junit.Test;
|
||||
|
||||
import org.springframework.boot.test.system.OutputCaptureRule;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Spencer Gibb
|
||||
@@ -38,28 +37,35 @@ public class DeployerApplicationTests {
|
||||
public void testDefaultLibrary() throws Exception {
|
||||
DeployerApplication wrapper = new DeployerApplication();
|
||||
if (System.getProperty("project.version") != null) {
|
||||
assertThat(wrapper.getVersion(),
|
||||
containsString(System.getProperty("project.version")));
|
||||
assertThat(wrapper.getVersion())
|
||||
.contains(System.getProperty("project.version"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateClassLoaderAndListDeployables() throws Exception {
|
||||
new DeployerApplication("--launcher.list=true").run();
|
||||
assertThat(output.toString(), containsString("configserver"));
|
||||
assertThat(output.toString()).contains("configserver");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNonOptionArgsPassedDown() throws Exception {
|
||||
new DeployerApplication("--launcher.list=true", "--spring.profiles.active=test")
|
||||
.run();
|
||||
assertThat(output.toString(), containsString("foo"));
|
||||
assertThat(output.toString()).contains("foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidDeployableFails() throws Exception {
|
||||
new DeployerApplication("--launcher.deploy=foo,bar").run();
|
||||
assertThat(output.toString(),
|
||||
containsString("The following are not valid: 'foo,bar'"));
|
||||
assertThat(output.toString())
|
||||
.contains("The following are not valid: 'foo,bar'");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultVersionReadFromFile() {
|
||||
String defaultVersion = new DeployerApplication("--launcher.deploy=foo,bar").getDefaultVersion();
|
||||
// starts with one or more digits then a .
|
||||
assertThat(defaultVersion).isNotBlank().containsPattern("^\\d+\\..*");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user