Skip to content

Instantly share code, notes, and snippets.

@sormuras
Created August 12, 2021 07:38
Show Gist options
  • Save sormuras/2faa19ce09825f9bb6ba45aca6c17079 to your computer and use it in GitHub Desktop.
Save sormuras/2faa19ce09825f9bb6ba45aca6c17079 to your computer and use it in GitHub Desktop.
Bach's (almost 17-M1) API
class build {
public static void main(String... args) {
var classes = Path.of(".bach/workspace/classes");
var modules = Path.of(".bach/workspace/modules");
try (var bach = Bach.of(args)) {
Call.tool("javac")
.with("--module", "com.greetings,org.astro")
.with("--module-source-path", ".")
.with("-d", classes)
.run(bach, Run::requireSuccessful);
Call.tool("directories", "clean", modules).run(bach, Run::requireSuccessful);
Stream.of(
Call.tool("jar")
.with("--create")
.with("--file", modules.resolve("com.greetings@99.jar"))
.with("--module-version", "99")
.with("--main-class", "com.greetings.Main")
.with("-C", classes.resolve("com.greetings"), "."),
Call.tool("jar")
.with("--create")
.with("--file", modules.resolve("org.astro@99.jar"))
.with("--module-version", "99")
.with("-C", classes.resolve("org.astro"), "."))
.parallel()
.map(bach::run)
.forEach(Run::requireSuccessful);
Call.module(ModuleFinder.of(modules), "com.greetings")
.run(
bach,
run -> run.output().lines().forEach(System.out::println),
Run::requireSuccessful);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment