swissquote / carnotzet

Modular and Re-usable Docker Environments using Maven
https://swissquote.github.io/carnotzet/
Apache License 2.0
49 stars 16 forks source link

Replace CommandRunner utility class with an abstraction and default implementation. #4

Closed ishestakov closed 7 years ago

ishestakov commented 7 years ago

Description

At the moment com.github.swissquote.carnotzet.runtime.docker.compose.DockerComposeRuntime uses com.github.swissquote.carnotzet.core.runtime.CommandRunner which is an utility class with all the static methods. The suggestion is to

Rationale.

For the purpose of gradle-carnotzet-plugin I'm working on, it's a blocking point as I need to provide alternative Gradle specific version to run processes. Moreover, doing so will allow to provide another specific implementations of CommandRunner interface e.g. for remote command execution (over SSH, etc.)

mryan43 commented 7 years ago

Could you elaborate a bit more ? what part doesn't work with gradle that require you to change this class ?

To my knowledge, this class is only a helper to simplify calls to ProcessBuilder, which is an abstraction that should remain below maven/gradle.

ishestakov commented 7 years ago

The crucial feature we need for Gradle is to set process output stream to System.out as only in that case the output of the process occurs on the build console as by default the build will run in a fork process and any other output instead of System.out won't be displayed. Also Gradle has it's own abstraction for running system process as well: ExecHandle (which actually uses ProcessBuilder under the hood).

The idea is to provide the adapter between Gradle abstraction for executing system processes and Carnotzet CommandRunner. Moreover using this approach anybody would be able to provide any decorators to instrument the CommandRunner in any suitable way (as mentioned above for remote SSH execution, log output to the console and log file at the same time, etc.)

ishestakov commented 7 years ago

Moreover the abstraction will simplify unit testing.