Small library for making it easier to spawn processes in java with a modern api.
AysncProcess comes with a few static methods, to either create a builder that can be launched by
calling start()
.
Prepare a command and then spawn it:
AsyncProcess.cmd("echo", "foo").start();
Or calling the run()
method to directly spawn a command
AsyncProcess.run("echo", "foo");
The run method is overloaded to make it possible to directly spawn commands with stdin/out/err set, it is recommended to use the builder created by the cmd builder in order to get clearer code though.
Here the cmd method is imported statically:
cmd("echo", "foo")
.in(supplier)
.out(consumer)
.err(consumer)
.start();
In sets the stdin supplier, expected to be of type Supplier<String>
it expected to block when it
doesn't have data and the supplier will never be called again after supplying a null value.
<dependency>
<groupId>sh.nerd</groupId>
<artifactId>async-process</artifactId>
<version>$VERSION</version>
</dependency>
- Give the user the possibility to specify environment through a hashmap
- Go through handling of the communication threads and verify the paths
- Better documentation
- Any other TODOs in the code.