Fixed invalid system props tokenizing
This commit is contained in:
@@ -106,10 +106,16 @@ public class ProjectBuilder {
|
||||
*/
|
||||
private String[] substituteSystemProps(String... commands) {
|
||||
boolean containsSystemProps = this.properties.getMaven().getSystemProperties().contains("-D");
|
||||
String[] splitSystemProps = StringUtils.tokenizeToStringArray(this.properties.getMaven()
|
||||
String[] splitSystemProps = StringUtils.delimitedListToStringArray(this.properties.getMaven()
|
||||
.getSystemProperties(), "-D");
|
||||
// first element might be empty even though the second one contains values
|
||||
if (splitSystemProps.length > 1) {
|
||||
splitSystemProps = StringUtils.isEmpty(splitSystemProps[0]) ?
|
||||
Arrays.copyOfRange(splitSystemProps, 1, splitSystemProps.length) :
|
||||
splitSystemProps;
|
||||
}
|
||||
String[] systemPropsWithPrefix = containsSystemProps ? Arrays.stream(splitSystemProps)
|
||||
.map(s -> "-D" + s)
|
||||
.map(s -> "-D" + s.trim())
|
||||
.collect(Collectors.toList())
|
||||
.toArray(new String[splitSystemProps.length]) : splitSystemProps;
|
||||
final AtomicInteger index = new AtomicInteger(-1);
|
||||
|
||||
@@ -133,14 +133,14 @@ public class ProjectBuilderTests {
|
||||
public void should_successfully_execute_a_deploy_command_with_sys_props_placeholder() throws Exception {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getMaven().setDeployCommand("echo \"{{systemProps}}\"");
|
||||
properties.getMaven().setSystemProperties("hello world");
|
||||
properties.getMaven().setSystemProperties("-Dhello=hello-world");
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
ProjectBuilder builder = new ProjectBuilder(properties, executor(properties));
|
||||
|
||||
builder.deploy();
|
||||
|
||||
then(asString(tmpFile("/builder/resolved/resolved.log")))
|
||||
.contains("hello world");
|
||||
.contains("-Dhello=hello-world");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user