Skip to content

Commit

Permalink
Fix pruning of build-related classes
Browse files Browse the repository at this point in the history
  • Loading branch information
sormuras committed May 24, 2024
1 parent 914e8fa commit 9ccb514
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
19 changes: 10 additions & 9 deletions .bach/src/run.bach/run/Project.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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());
Expand All @@ -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));
}
}

Expand Down
2 changes: 1 addition & 1 deletion .bach/src/run.bach/run/bach
Submodule bach updated 1 files
+13 −2 workflow/Cleaner.java

0 comments on commit 9ccb514

Please sign in to comment.