Skip to content

Commit

Permalink
Add string escape for classpath with spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
melix committed Mar 18, 2022
1 parent 79bb32e commit 064ac27
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public List<String> build() {
return convertToArgsFile(options
.stream()
.map(CliOption::getOptions)
.map(args -> String.join(" ", args))
.map(args -> args.stream().map(NativeImageUtils::escapeArg).collect(Collectors.joining(" ")))
.collect(Collectors.toList())
);
} else {
Expand All @@ -126,6 +126,14 @@ public List<String> build() {
}
}

private static String escapeArg(String arg) {
arg = arg.replace("\\", "\\\\");
if (arg.contains(" ")) {
arg = "\"" + arg + "\"";
}
return arg;
}

private static final class CliOption {
private final List<String> options;

Expand Down

0 comments on commit 064ac27

Please sign in to comment.