From 551c4b987f9d0f613eab658033b564a5502f1fab Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Wed, 6 Jan 2016 23:44:49 -0800 Subject: [PATCH] Update to new architecture. --- Build.kt => kobalt/src/Build.kt | 5 ++- kobalt/wrapper/kobalt-wrapper.properties | 2 +- .../plugin/linecount/LineCountPlugin.kt | 31 ++++++++----------- src/main/resources/META-INF/plugin.xml | 6 ++-- 4 files changed, 19 insertions(+), 25 deletions(-) rename Build.kt => kobalt/src/Build.kt (81%) diff --git a/Build.kt b/kobalt/src/Build.kt similarity index 81% rename from Build.kt rename to kobalt/src/Build.kt index 4d6747b..0c88381 100644 --- a/Build.kt +++ b/kobalt/src/Build.kt @@ -17,11 +17,10 @@ val project = kotlinProject { name = "kobalt-line-count" group = "com.beust.kobalt" artifactId = name - version = "0.16" + version = "0.17" dependencies { -// compile("file:" + homeDir("kotlin/kobalt/kobaltBuild/libs/kobalt-0.168.jar")) - compile("com.beust:kobalt:0.226") + compile("com.beust:kobalt-plugin-api:") } assemble { diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties index 5ea33a2..119b07a 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=0.226 \ No newline at end of file +kobalt.version=0.388 \ No newline at end of file diff --git a/src/main/kotlin/com/beust/kobalt/plugin/linecount/LineCountPlugin.kt b/src/main/kotlin/com/beust/kobalt/plugin/linecount/LineCountPlugin.kt index fe52da3..cf842dc 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/linecount/LineCountPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/linecount/LineCountPlugin.kt @@ -1,21 +1,25 @@ package com.beust.kobalt.plugin.linecount -import com.beust.kobalt.api.BasePlugin -import com.beust.kobalt.api.Kobalt -import com.beust.kobalt.api.KobaltContext -import com.beust.kobalt.api.Project +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.internal.TaskResult import com.beust.kobalt.misc.log import java.nio.file.* import java.nio.file.attribute.BasicFileAttributes -fun main(argv: Array) { - com.beust.kobalt.main(argv) -} +//fun main(argv: Array) { +// com.beust.kobalt.main(argv) +//} + +public class LineCountPlugin : BasePlugin(), ITaskContributor { + override fun tasksFor(context: KobaltContext) + = listOf(DynamicTask(this, "dynamicTask", "Dynamic task", runBefore = listOf("compile"), + closure = { project -> + println("Running dynamic task") + TaskResult() + })) -public class LineCountPlugin : BasePlugin() { companion object { const val NAME : String = "kobalt-line-count" } @@ -23,15 +27,6 @@ public class LineCountPlugin : BasePlugin() { var info: LineCountInfo = LineCountInfo() - override fun apply(project: Project, context: KobaltContext) { - println("*** Applying plugin $name with project $project") - println("*** Adding dynamic task") - addTask(project, "dynamicTask", runBefore = listOf("compile")) { - println("Dynamic task") - TaskResult() - } - } - @Task(name = "lineCount", description = "Count the lines", runBefore = arrayOf("compile")) fun lineCount(project: Project): TaskResult { var fileCount = 0 diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 79b9ef9..84b2d06 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -1,6 +1,6 @@ kobalt-line-count - + com.beust.kobalt.plugin.linecount.LineCountPlugin - - \ No newline at end of file + +