Skip to content

Commit

Permalink
Create parent directories if it doesn't exists
Browse files Browse the repository at this point in the history
  • Loading branch information
hvvikram committed Feb 24, 2023
1 parent 5763130 commit 6f1e375
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ public void export(Set<ExternalDependency> dependencies) {
.collect(Collectors.toSet());

Gson gson = new GsonBuilder().setPrettyPrinting().create();
Path path = Paths.get(exportDependenciesExtension.getFile());
Files.createDirectories(path.getParent());
try (BufferedWriter writer =
Files.newBufferedWriter(
Paths.get(exportDependenciesExtension.getFile()), StandardCharsets.UTF_8)) {
Files.newBufferedWriter(path, StandardCharsets.UTF_8)) {
LOG.info("Exporting dependencies to JSON at " + exportDependenciesExtension.getFile());
gson.toJson(dependencyModels, writer);
} catch (IOException e) {
Expand Down

0 comments on commit 6f1e375

Please sign in to comment.