mirror of
https://github.com/ethauvin/kobalt-line-count.git
synced 2025-04-25 03:07:11 -07:00
Use ITaskContributor.
This commit is contained in:
parent
79242e1d82
commit
fbb27d246d
1 changed files with 11 additions and 15 deletions
|
@ -1,12 +1,9 @@
|
||||||
package com.beust.kobalt.plugin.linecount
|
package com.beust.kobalt.plugin.linecount
|
||||||
|
|
||||||
import com.beust.kobalt.api.BasePlugin
|
import com.beust.kobalt.TaskResult
|
||||||
import com.beust.kobalt.api.Kobalt
|
import com.beust.kobalt.api.*
|
||||||
import com.beust.kobalt.api.KobaltContext
|
|
||||||
import com.beust.kobalt.api.Project
|
|
||||||
import com.beust.kobalt.api.annotation.Directive
|
import com.beust.kobalt.api.annotation.Directive
|
||||||
import com.beust.kobalt.api.annotation.Task
|
import com.beust.kobalt.api.annotation.Task
|
||||||
import com.beust.kobalt.internal.TaskResult
|
|
||||||
import com.beust.kobalt.misc.log
|
import com.beust.kobalt.misc.log
|
||||||
import java.nio.file.*
|
import java.nio.file.*
|
||||||
import java.nio.file.attribute.BasicFileAttributes
|
import java.nio.file.attribute.BasicFileAttributes
|
||||||
|
@ -15,7 +12,15 @@ fun main(argv: Array<String>) {
|
||||||
com.beust.kobalt.main(argv)
|
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 {
|
companion object {
|
||||||
const val NAME : String = "kobalt-line-count"
|
const val NAME : String = "kobalt-line-count"
|
||||||
}
|
}
|
||||||
|
@ -23,15 +28,6 @@ public class LineCountPlugin : BasePlugin() {
|
||||||
|
|
||||||
var info: LineCountInfo = LineCountInfo()
|
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"))
|
@Task(name = "lineCount", description = "Count the lines", runBefore = arrayOf("compile"))
|
||||||
fun lineCount(project: Project): TaskResult {
|
fun lineCount(project: Project): TaskResult {
|
||||||
var fileCount = 0
|
var fileCount = 0
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue