From 9ccb514f69394db3419f6b7981992349254c8397 Mon Sep 17 00:00:00 2001 From: Christian Stein Date: Fri, 24 May 2024 09:27:07 +0200 Subject: [PATCH] Fix pruning of build-related classes --- .bach/src/run.bach/run/Project.java | 19 ++++++++++--------- .bach/src/run.bach/run/bach | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.bach/src/run.bach/run/Project.java b/.bach/src/run.bach/run/Project.java index 078534eb2..96e92e616 100644 --- a/.bach/src/run.bach/run/Project.java +++ b/.bach/src/run.bach/run/Project.java @@ -1,7 +1,6 @@ package run; import java.lang.module.ModuleFinder; -import java.nio.file.Files; import java.util.Optional; import run.bach.ModuleFinders; import run.bach.ToolCall; @@ -44,7 +43,11 @@ static Project ofCurrentWorkingDirectory() { return new Project(verbose, new Workflow(folders, structure, runner)); } - void printStatus() { + public Space space(String name) { + return workflow.structure().spaces().space(name); + } + + public void printStatus() { var structure = workflow.structure(); System.out.println(structure.toNameAndVersion()); System.out.println(structure.basics()); @@ -62,14 +65,12 @@ public boolean builderDoesCleanAtTheBeginning() { @Override public void classesCompilerRunJavacToolCall(ToolCall javac) { run(javac.add("-X" + "lint:all").add("-W" + "error")); - // Delete all local programs in out/main/classes/*/run.bach/run/* directory + // Retain only "bach" subdirectory in out/main/classes/*/run.bach/run/* directory if (ClassesCompiler.space().name().equals("main")) { - var dir = classesCompilerUsesDestinationDirectory().resolve("run.bach", "run"); - try (var stream = Files.newDirectoryStream(dir, Files::isRegularFile)) { - for (var file : stream) Files.deleteIfExists(file); - } catch (Exception exception) { - throw new RuntimeException(exception); - } + var classes = classesCompilerUsesDestinationDirectory(); + var run = classes.resolve("run.bach", "run"); + var bach = run.resolve("bach"); + cleanerPrune(run, path -> !path.equals(bach)); } } diff --git a/.bach/src/run.bach/run/bach b/.bach/src/run.bach/run/bach index d1e95c439..94416e4e9 160000 --- a/.bach/src/run.bach/run/bach +++ b/.bach/src/run.bach/run/bach @@ -1 +1 @@ -Subproject commit d1e95c43994877fcf479f942a9bdee21c45d71d7 +Subproject commit 94416e4e9fad71e57d5b42911dfd61a8861f9014