package build;

import com.github.sormuras.bach.Bach;
import com.github.sormuras.bach.BuildProgram;
import com.github.sormuras.bach.Project;
import com.github.sormuras.bach.ProjectBuilder;
import com.github.sormuras.bach.ProjectInfo;
import com.github.sormuras.bach.project.Base;
import java.time.Duration;
import java.time.Instant;

public class BachBuildProgram implements BuildProgram {

  public static void main(String... args) {
    new BachBuildProgram().build(Bach.ofSystem(), args);
  }

  public BachBuildProgram() {}

  @Override
  public void build(Bach bach, String... args) {
    var out = bach.printStream();
    var err = System.err;

    var info = getClass().getModule().getAnnotation(ProjectInfo.class);
    var project = Project.of(Base.ofCurrentDirectory(), info);
    out.println("Build Bach " + project.version() + " // @" + project.main().jarslug() + ".jar");

    var start = Instant.now();
    try {
      new ProjectBuilder(bach, project).build();
    } catch (Exception exception) {
      err.println(exception);
    } finally {
      out.printf("Build took %d milliseconds%n", Duration.between(start, Instant.now()).toMillis());
    }
  }

  @Override
  public String toString() {
    return "Bach's Build Program";
  }
}

@@ -878,16 +878,224 @@
 jar%22);%0A%0A
+    System.clearProperty(%22bach.project.name%22);%0A    System.clearProperty(%22bach.project.version%22);%0A    System.clearProperty(%22bach.project.main.release%22);%0A    System.clearProperty(%22bach.project.main.jarslug%22);%0A%0A
     var 

Clear well-known system properties in Bach's build program