diff --git a/example/kobalt/src/Build.kt b/example/kobalt/src/Build.kt index f6d3d5f..e226bfa 100644 --- a/example/kobalt/src/Build.kt +++ b/example/kobalt/src/Build.kt @@ -4,8 +4,9 @@ import com.beust.kobalt.plugin.application.* import com.beust.kobalt.plugin.java.* import net.thauvin.erik.kobalt.plugin.exec.* -//val pl = plugins(file("../kobaltBuild/libs/kobalt-exec-0.6.2.jar")) -val pl = plugins("net.thauvin.erik:kobalt-exec:0.6.2") +val bs = buildScript { + plugins("net.thauvin.erik:kobalt-exec:0.6.2") +} val example = project { diff --git a/src/main/kotlin/net/thauvin/erik/kobalt/plugin/exec/ExecPlugin.kt b/src/main/kotlin/net/thauvin/erik/kobalt/plugin/exec/ExecPlugin.kt index fb99d3a..2c9fb06 100644 --- a/src/main/kotlin/net/thauvin/erik/kobalt/plugin/exec/ExecPlugin.kt +++ b/src/main/kotlin/net/thauvin/erik/kobalt/plugin/exec/ExecPlugin.kt @@ -1,7 +1,7 @@ /* * ExecPlugin.kt * - * Copyright (c) 2016, Erik C. Thauvin (erik@thauvin.net) + * Copyright (c) 2016-2017, Erik C. Thauvin (erik@thauvin.net) * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -60,6 +60,7 @@ class ExecPlugin @Inject constructor(val configActor: ConfigActor) : override val name = NAME + @Suppress("unused") @Task(name = "exec", description = "Execute a command line process.") fun taskExec(project: Project): TaskResult { var result = TaskResult() @@ -109,7 +110,7 @@ class ExecPlugin @Inject constructor(val configActor: ConfigActor) : for ((args, dir, os, fail) in config.commandLines) { val wrkDir = File(if (dir.isNullOrBlank()) project.directory else dir) if (wrkDir.isDirectory) { - var execute = (os.size == 0) + var execute = (os.isEmpty()) if (!execute) { for (name in os) { execute = matchOs(name) @@ -126,7 +127,7 @@ class ExecPlugin @Inject constructor(val configActor: ConfigActor) : val stderr = if (proc.errorStream.available() > 0) fromStream(proc.errorStream) else emptyList() val cmdInfo = "Program \"" + args.joinToString(" ") + "\" (in directory \"${wrkDir.path}\"): " - if (err == false) { + if (!err) { errorMessage.append(cmdInfo).append("TIMEOUT") success = false } else if (!fail.contains(Fail.NONE)) { @@ -176,11 +177,11 @@ class ExecPlugin @Inject constructor(val configActor: ConfigActor) : } } -enum class Fail() { +enum class Fail { ALL, EXIT, NONE, NORMAL, OUTPUT, STDERR, STDOUT } -enum class Os() { +enum class Os { FREEBSD, LINUX, MAC, OPENVMS, OS400, SOLARIS, TANDEM, WINDOWS, ZOS } @@ -188,15 +189,17 @@ data class CommandLine(var args: List = emptyList(), var dir: String = " var fail: Set = setOf(Fail.NORMAL)) @Directive -class ExecConfig() { +class ExecConfig { val commandLines = arrayListOf() + @Suppress("unused") fun commandLine(args: List = emptyList(), dir: String = "", os: Set = emptySet(), fail: Set = setOf(Fail.NORMAL)) { - if (args.size > 0) commandLines.add(CommandLine(args, dir, os, fail)) + if (args.isNotEmpty()) commandLines.add(CommandLine(args, dir, os, fail)) } } +@Suppress("unused") @Directive fun Project.exec(init: ExecConfig.() -> Unit) { ExecConfig().let { config ->