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..586d6d8 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/linecount/LineCountPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/linecount/LineCountPlugin.kt @@ -1,12 +1,9 @@ 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 @@ -15,7 +12,15 @@ fun main(argv: Array) { com.beust.kobalt.main(argv) } -public class LineCountPlugin : BasePlugin() { +public class LineCountPlugin : BasePlugin(), ITaskContributor { + + // ITaskContributor + override fun tasksFor(context: KobaltContext) = listOf( + DynamicTask(this, "dynamicTask", "Dynamic task", runBefore = listOf("compile"), closure = { + TaskResult() + }) + ) + companion object { const val NAME : String = "kobalt-line-count" } @@ -23,15 +28,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