Skip to content

A small library that wraps process execution in completable futures.

License

Notifications You must be signed in to change notification settings

lndbrg/java-async-process

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Async Process

Maven Central Travis Codecov codebeat badge

Small library for making it easier to spawn processes in java with a modern api.

Usage

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.

Advanced usage

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.

In pom.xml

<dependency>
  <groupId>sh.nerd</groupId>
  <artifactId>async-process</artifactId>
  <version>$VERSION</version>
</dependency>

Todo

  • 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.

About

A small library that wraps process execution in completable futures.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages