1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-25 07:57:12 -07:00

Added ignoreInputStream, ignoreErrorStream and ignoreExitvalue to the application plugin.

This commit is contained in:
Erik C. Thauvin 2017-11-08 01:05:16 -08:00
parent be40f5c81d
commit 20a01f8de0
2 changed files with 20 additions and 4 deletions

View file

@ -19,6 +19,7 @@ class RunCommandInfo {
*/
var useErrorStreamAsErrorIndicator : Boolean = true
var useInputStreamAsErrorIndicator : Boolean = false
var ignoreExitValue : Boolean = false
var errorCallback: Function1<List<String>, Unit> = NewRunCommand.DEFAULT_ERROR
var successCallback: Function1<List<String>, Unit> = NewRunCommand.DEFAULT_SUCCESS
@ -89,10 +90,14 @@ open class NewRunCommand(val info: RunCommandInfo) {
// Check to see if the command succeeded
val isSuccess =
if (info.containsErrors != null) ! info.containsErrors!!(error)
else isSuccess(returnCode, input, error)
else isSuccess(if (info.ignoreExitValue) true else returnCode, input, error)
if (isSuccess) {
info.successCallback(input)
if (!info.useErrorStreamAsErrorIndicator) {
info.successCallback(error + input)
} else {
info.successCallback(input)
}
} else {
info.errorCallback(error + input)
}
@ -105,7 +110,7 @@ open class NewRunCommand(val info: RunCommandInfo) {
* have various ways to signal errors.
*/
open protected fun isSuccess(isSuccess: Boolean, input: List<String>, error: List<String>) : Boolean {
var hasErrors = ! isSuccess
var hasErrors: Boolean = ! isSuccess
if (info.useErrorStreamAsErrorIndicator && ! hasErrors) {
hasErrors = hasErrors || error.isNotEmpty()
}

View file

@ -17,7 +17,6 @@ import com.beust.kobalt.plugin.packaging.PackageConfig
import com.beust.kobalt.plugin.packaging.PackagingPlugin
import com.google.inject.Inject
import com.google.inject.Singleton
import org.jetbrains.kotlin.config.TargetPlatformVersion.NoVersion.description
import java.io.File
class ApplicationConfig {
@ -34,6 +33,15 @@ class ApplicationConfig {
@Directive
fun args(vararg argv: String) = argv.forEach { args.add(it) }
val args = arrayListOf<String>()
@Directive
var ignoreErrorStream: Boolean = false
@Directive
var ignoreInputStream: Boolean = true
@Directive
var ignoreExitValue: Boolean = false
}
@Directive
@ -147,6 +155,9 @@ class ApplicationPlugin @Inject constructor(val configActor: ConfigsActor<Applic
kobaltLog(1, "ERROR")
kobaltLog(1, output.joinToString("\n"))
}
useErrorStreamAsErrorIndicator = !config.ignoreErrorStream
useInputStreamAsErrorIndicator = !config.ignoreInputStream
ignoreExitValue = config.ignoreExitValue
}
return TaskResult(exitCode == 0)
}