Skip to content

Commit

Permalink
Fix ManifestMergerAction test case on windows
Browse files Browse the repository at this point in the history
`manifest.toString().replaceFirst("^/", "")` silently fails on windows machines causing `removePermissions` to write to the original test file. This pull request creates a new temp file that `removePermissions` can write the modified manifest to.

Pulling this change out of another PR so that it's easier to merge. Original PR here https://github.com/bazelbuild/bazel/pull/13445/files#r631575251

Closes #13760.

PiperOrigin-RevId: 438643774
  • Loading branch information
Bencodes authored and Copybara-Service committed Mar 31, 2022
1 parent dbb6e99 commit be84e16
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,8 @@ private static Path removePermissions(Path manifest, Path outputDir)
}
}
}
// Write resulting manifest to the output directory, maintaining full path to prevent collisions
Path output = outputDir.resolve(manifest.toString().replaceFirst("^/", ""));
Files.createDirectories(output.getParent());
// Write resulting manifest to a tmp file to prevent collisions
Path output = Files.createTempFile(outputDir, "AndroidManifest", ".xml");
TransformerFactory.newInstance()
.newTransformer()
.transform(new DOMSource(doc), new StreamResult(output.toFile()));
Expand Down

0 comments on commit be84e16

Please sign in to comment.