commit bce3a325759938bab2ef231c80148b0865e169d1 Author: Erik C. Thauvin Date: Sun Jul 10 21:29:09 2016 -0700 Initial commit. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..87ff9b0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,29 @@ +**/.idea/dictionaries +**/.idea/gradle.xml +**/.idea/libraries +**/.idea/tasks.xml +**/.idea/workspace.xml +*.iws +.DS_Store +.classpath +.gradle +.kobalt +.nb-gradle +.project +.settings +/bin +/build +/deploy +/dist +/gen +/gradle.properties +/libs +/local.properties +/out +/proguard-project.txt +/project.properties +/target +/test-output +Thumbs.db +ehthumbs.db +kobaltBuild \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..a852314 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/.idea/copyright/Erik_s_Copyright_Notice.xml b/.idea/copyright/Erik_s_Copyright_Notice.xml new file mode 100644 index 0000000..5cd1489 --- /dev/null +++ b/.idea/copyright/Erik_s_Copyright_Notice.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml new file mode 100644 index 0000000..2bbc8ca --- /dev/null +++ b/.idea/copyright/profiles_settings.xml @@ -0,0 +1,11 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..97626ba --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..8ff795e --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,53 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..3b31283 --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/.idea/kobalt.xml b/.idea/kobalt.xml new file mode 100644 index 0000000..18044a8 --- /dev/null +++ b/.idea/kobalt.xml @@ -0,0 +1,29 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..30626e1 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..47c9da8 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/scopes/Source.xml b/.idea/scopes/Source.xml new file mode 100644 index 0000000..5ed504c --- /dev/null +++ b/.idea/scopes/Source.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/example/example.iml b/example/example.iml new file mode 100644 index 0000000..514e55d --- /dev/null +++ b/example/example.iml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/example/kobalt/src/Build.kt b/example/kobalt/src/Build.kt new file mode 100644 index 0000000..ab4c586 --- /dev/null +++ b/example/kobalt/src/Build.kt @@ -0,0 +1,37 @@ +import com.beust.kobalt.* +import com.beust.kobalt.plugin.packaging.* +import com.beust.kobalt.plugin.application.* +import com.beust.kobalt.plugin.java.* +//import net.thauvin.erik.kobalt.plugin.exec.* + +val p = project { + + name = "example" + group = "com.example" + artifactId = name + version = "0.1" + + sourceDirectories { + path("src/main/java") + } + + sourceDirectoriesTest { + path("src/test/java") + } + + dependencies { + compile(file("../libs/kobalt-exec-0.1.jar")) + } + + dependenciesTest { + } + + assemble { + jar { + } + } + + application { + mainClass = "com.example.Main" + } +} diff --git a/example/kobalt/wrapper/kobalt-wrapper.jar b/example/kobalt/wrapper/kobalt-wrapper.jar new file mode 100644 index 0000000..f40ec90 Binary files /dev/null and b/example/kobalt/wrapper/kobalt-wrapper.jar differ diff --git a/example/kobalt/wrapper/kobalt-wrapper.properties b/example/kobalt/wrapper/kobalt-wrapper.properties new file mode 100644 index 0000000..40e4395 --- /dev/null +++ b/example/kobalt/wrapper/kobalt-wrapper.properties @@ -0,0 +1 @@ +kobalt.version=0.843 \ No newline at end of file diff --git a/example/kobaltw b/example/kobaltw new file mode 100644 index 0000000..b27b3d8 --- /dev/null +++ b/example/kobaltw @@ -0,0 +1 @@ +java -jar $(dirname $0)/kobalt/wrapper/kobalt-wrapper.jar $* diff --git a/example/src/main/java/com/example/Main.java b/example/src/main/java/com/example/Main.java new file mode 100644 index 0000000..c07945d --- /dev/null +++ b/example/src/main/java/com/example/Main.java @@ -0,0 +1,7 @@ +package com.example; + +class Main { + public static void main(String[] argv) { + System.out.println("\n\nHello Java world from Kobalt\n\n"); + } +} \ No newline at end of file diff --git a/example/src/test/java/com/example/ExampleTest.java b/example/src/test/java/com/example/ExampleTest.java new file mode 100644 index 0000000..2da4817 --- /dev/null +++ b/example/src/test/java/com/example/ExampleTest.java @@ -0,0 +1,9 @@ +package com.example; +import org.testng.annotations.Test; + +public class ExampleTest { + @Test + public void f() { + System.out.println("Running test"); + } +} \ No newline at end of file diff --git a/kobalt-exec.iml b/kobalt-exec.iml new file mode 100644 index 0000000..fa44f8b --- /dev/null +++ b/kobalt-exec.iml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/kobalt/Build.kt.iml b/kobalt/Build.kt.iml new file mode 100644 index 0000000..7bc9dd6 --- /dev/null +++ b/kobalt/Build.kt.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/kobalt/src/Build.kt b/kobalt/src/Build.kt new file mode 100644 index 0000000..8fe41de --- /dev/null +++ b/kobalt/src/Build.kt @@ -0,0 +1,37 @@ +import com.beust.kobalt.plugin.packaging.assemble +import com.beust.kobalt.project +import com.beust.kobalt.repos + +val repos = repos() + +val dev = true +val kobaltDependency = if (dev) "kobalt" else "kobalt-plugin-api" + +val p = project { + + name = "kobalt-exec" + group = "net.thauvin.erik.kobalt" + artifactId = name + version = "0.1" + + sourceDirectories { + path("src/main/kotlin") + } + + sourceDirectoriesTest { + path("src/test/kotlin") + } + + dependencies { + compile("com.beust:$kobaltDependency:0.725") + } + + dependenciesTest { + compile("org.testng:testng:") + + } + + assemble { + jar {} + } +} diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties new file mode 100644 index 0000000..40e4395 --- /dev/null +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -0,0 +1 @@ +kobalt.version=0.843 \ No newline at end of file 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 new file mode 100644 index 0000000..1556b9b --- /dev/null +++ b/src/main/kotlin/net/thauvin/erik/kobalt/plugin/exec/ExecPlugin.kt @@ -0,0 +1,101 @@ +/* + * ExecPlugin.kt + * + * Copyright (c) 2016, Erik C. Thauvin (erik@thauvin.net) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of this project nor the names of its contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.thauvin.erik.kobalt.plugin.exec + +import com.beust.kobalt.TaskResult +import com.beust.kobalt.api.* +import com.beust.kobalt.api.annotation.Directive +import com.beust.kobalt.api.annotation.Task +import com.beust.kobalt.misc.log + +class ExecPlugin : BasePlugin(), ITaskContributor { + + fun main(argv: Array) { + com.beust.kobalt.main(argv) + } + + // ITaskContributor + override fun tasksFor(context: KobaltContext): List { + return emptyList() + } + + + companion object { + const val NAME: String = "kobalt-exec" + } + + override val name = NAME + + @Task(name = "exec", description = "Executes a command line process.") + fun taskExec(project: Project): TaskResult { + return executeCommands(project) + } + + private fun executeCommands(project: Project): TaskResult { + var success = false + val config = configs[project.name] + + if (config != null) { + config.commandLines.forEach { + log(2, "Executing: '" + { it.args.joinToString { " " } } + "' in '{$it.dir}'") + success = true + } + } + + return TaskResult(success) + } + + private val configs = hashMapOf() + fun addExecConfig(projectName: String, config: ExecConfig) { + configs.put(projectName, config) + } +} + +data class CommandLine(var os: String = "", var dir: String = "", var args: Array = emptyArray()) + +data class ExecConfig(val project: Project) { + val commandLines = arrayListOf() + + @Directive + public fun commandLine(os: String = "", dir: String = "", args: Array = emptyArray()) { + if (args.size > 0) commandLines.add(CommandLine(os, dir, args)) + } +} + +@Directive +fun Project.exec(init: ExecConfig.() -> Unit): ExecConfig { + with(ExecConfig(this)) { + init() + (Kobalt.findPlugin(ExecPlugin.NAME) as ExecPlugin).addExecConfig(name, this) + return this + } +} \ No newline at end of file diff --git a/src/main/resources/META-INF/kobalt-plugin.xml b/src/main/resources/META-INF/kobalt-plugin.xml new file mode 100644 index 0000000..1cab08a --- /dev/null +++ b/src/main/resources/META-INF/kobalt-plugin.xml @@ -0,0 +1,6 @@ + + kobalt-exec + + net.thauvin.erik.kobalt.plugin.exec.ExecPlugin + + \ No newline at end of file diff --git a/src/test/kotlin/com/example/MainTest.kt b/src/test/kotlin/com/example/MainTest.kt new file mode 100644 index 0000000..c2a547d --- /dev/null +++ b/src/test/kotlin/com/example/MainTest.kt @@ -0,0 +1,39 @@ +/* + * MainTest.kt + * + * Copyright (c) 2016, Erik C. Thauvin (erik@thauvin.net) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of this project nor the names of its contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.example + +import org.testng.annotations.Test + +class ExampleTest { + @Test + fun f() = println("Running test") +} \ No newline at end of file