mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 00:17:11 -07:00
Added ignoreInputStream, ignoreErrorStream and ignoreExitvalue to the application plugin.
This commit is contained in:
parent
be40f5c81d
commit
20a01f8de0
2 changed files with 20 additions and 4 deletions
|
@ -19,6 +19,7 @@ class RunCommandInfo {
|
||||||
*/
|
*/
|
||||||
var useErrorStreamAsErrorIndicator : Boolean = true
|
var useErrorStreamAsErrorIndicator : Boolean = true
|
||||||
var useInputStreamAsErrorIndicator : Boolean = false
|
var useInputStreamAsErrorIndicator : Boolean = false
|
||||||
|
var ignoreExitValue : Boolean = false
|
||||||
|
|
||||||
var errorCallback: Function1<List<String>, Unit> = NewRunCommand.DEFAULT_ERROR
|
var errorCallback: Function1<List<String>, Unit> = NewRunCommand.DEFAULT_ERROR
|
||||||
var successCallback: Function1<List<String>, Unit> = NewRunCommand.DEFAULT_SUCCESS
|
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
|
// Check to see if the command succeeded
|
||||||
val isSuccess =
|
val isSuccess =
|
||||||
if (info.containsErrors != null) ! info.containsErrors!!(error)
|
if (info.containsErrors != null) ! info.containsErrors!!(error)
|
||||||
else isSuccess(returnCode, input, error)
|
else isSuccess(if (info.ignoreExitValue) true else returnCode, input, error)
|
||||||
|
|
||||||
if (isSuccess) {
|
if (isSuccess) {
|
||||||
|
if (!info.useErrorStreamAsErrorIndicator) {
|
||||||
|
info.successCallback(error + input)
|
||||||
|
} else {
|
||||||
info.successCallback(input)
|
info.successCallback(input)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
info.errorCallback(error + input)
|
info.errorCallback(error + input)
|
||||||
}
|
}
|
||||||
|
@ -105,7 +110,7 @@ open class NewRunCommand(val info: RunCommandInfo) {
|
||||||
* have various ways to signal errors.
|
* have various ways to signal errors.
|
||||||
*/
|
*/
|
||||||
open protected fun isSuccess(isSuccess: Boolean, input: List<String>, error: List<String>) : Boolean {
|
open protected fun isSuccess(isSuccess: Boolean, input: List<String>, error: List<String>) : Boolean {
|
||||||
var hasErrors = ! isSuccess
|
var hasErrors: Boolean = ! isSuccess
|
||||||
if (info.useErrorStreamAsErrorIndicator && ! hasErrors) {
|
if (info.useErrorStreamAsErrorIndicator && ! hasErrors) {
|
||||||
hasErrors = hasErrors || error.isNotEmpty()
|
hasErrors = hasErrors || error.isNotEmpty()
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@ import com.beust.kobalt.plugin.packaging.PackageConfig
|
||||||
import com.beust.kobalt.plugin.packaging.PackagingPlugin
|
import com.beust.kobalt.plugin.packaging.PackagingPlugin
|
||||||
import com.google.inject.Inject
|
import com.google.inject.Inject
|
||||||
import com.google.inject.Singleton
|
import com.google.inject.Singleton
|
||||||
import org.jetbrains.kotlin.config.TargetPlatformVersion.NoVersion.description
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
class ApplicationConfig {
|
class ApplicationConfig {
|
||||||
|
@ -34,6 +33,15 @@ class ApplicationConfig {
|
||||||
@Directive
|
@Directive
|
||||||
fun args(vararg argv: String) = argv.forEach { args.add(it) }
|
fun args(vararg argv: String) = argv.forEach { args.add(it) }
|
||||||
val args = arrayListOf<String>()
|
val args = arrayListOf<String>()
|
||||||
|
|
||||||
|
@Directive
|
||||||
|
var ignoreErrorStream: Boolean = false
|
||||||
|
|
||||||
|
@Directive
|
||||||
|
var ignoreInputStream: Boolean = true
|
||||||
|
|
||||||
|
@Directive
|
||||||
|
var ignoreExitValue: Boolean = false
|
||||||
}
|
}
|
||||||
|
|
||||||
@Directive
|
@Directive
|
||||||
|
@ -147,6 +155,9 @@ class ApplicationPlugin @Inject constructor(val configActor: ConfigsActor<Applic
|
||||||
kobaltLog(1, "ERROR")
|
kobaltLog(1, "ERROR")
|
||||||
kobaltLog(1, output.joinToString("\n"))
|
kobaltLog(1, output.joinToString("\n"))
|
||||||
}
|
}
|
||||||
|
useErrorStreamAsErrorIndicator = !config.ignoreErrorStream
|
||||||
|
useInputStreamAsErrorIndicator = !config.ignoreInputStream
|
||||||
|
ignoreExitValue = config.ignoreExitValue
|
||||||
}
|
}
|
||||||
return TaskResult(exitCode == 0)
|
return TaskResult(exitCode == 0)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue