Properly handle values with spaces

Closes gh-10741
This commit is contained in:
Stephane Nicoll
2018-04-24 16:26:51 +02:00
parent d4729f5389
commit fd47b728c1
4 changed files with 15 additions and 10 deletions

View File

@@ -569,18 +569,14 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
*/
static class SystemPropertyFormatter {
private static final String NO_VALUE_FORMAT = "-D%s";
private static final String KEY_VALUE_FORMAT = NO_VALUE_FORMAT + "=%s";
public static String format(Object key, Object value) {
if (key == null) {
return "";
}
if (value == null || String.valueOf(value).trim().isEmpty()) {
return String.format(NO_VALUE_FORMAT, key);
if (value == null || String.valueOf(value).isEmpty()) {
return String.format("-D%s", key);
}
return String.format(KEY_VALUE_FORMAT, key, value);
return String.format("-D%s=\"%s\"", key, value);
}
}