Skip to content

Commit 1da40ee

Browse files
committed
gradle: Escape path to original bndrun file
In the off chance the bndrun file has a double quote in the name. We also use `~` to allow the output bndrun file's -runbundles to not be overwritten by the original bndrun file's -runbundles, if any. Signed-off-by: BJ Hargrave <[email protected]>
1 parent 1a62b9f commit 1da40ee

File tree

1 file changed

+14
-1
lines changed
  • gradle-plugins/biz.aQute.bnd.gradle/src/main/java/aQute/bnd/gradle

1 file changed

+14
-1
lines changed

gradle-plugins/biz.aQute.bnd.gradle/src/main/java/aQute/bnd/gradle/Resolve.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,14 +226,27 @@ protected biz.aQute.resolve.Bndrun createBndrun(Workspace workspace, File bndrun
226226
if (!Objects.equals(outputBndrunFile, bndrunFile)) {
227227
try (Writer writer = IO.writer(outputBndrunFile)) {
228228
UTF8Properties props = new UTF8Properties();
229-
props.setProperty(Constants.INCLUDE, String.format("\"%s\"", IO.absolutePath(bndrunFile)));
229+
props.setProperty(Constants.INCLUDE, String.format("\"~%s\"", escape(IO.absolutePath(bndrunFile))));
230230
props.store(writer, null);
231231
}
232232
bndrunFile = outputBndrunFile;
233233
}
234234
return super.createBndrun(workspace, bndrunFile);
235235
}
236236

237+
private String escape(String input) {
238+
final int length = input.length();
239+
StringBuilder sb = new StringBuilder(length);
240+
for (int i = 0; i < length;i++) {
241+
char c = input.charAt(i);
242+
if (c == '"') {
243+
sb.append('\\');
244+
}
245+
sb.append(c);
246+
}
247+
return sb.length() == length ? input : sb.toString();
248+
}
249+
237250
/**
238251
* Resolve the Bndrun object.
239252
*

0 commit comments

Comments
 (0)