1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt-line-count.git synced 2025-04-25 03:07:11 -07:00
This commit is contained in:
Cedric Beust 2017-02-20 09:18:39 -08:00
parent 83dbbc9fe1
commit c3ba642496
2 changed files with 7 additions and 4 deletions

View file

@ -20,7 +20,7 @@ val project = project {
version = "0.23" version = "0.23"
dependencies { dependencies {
compile("com.beust:kobalt-plugin-api:0.930") compile("com.beust:kobalt-plugin-api:0.939")
} }
assemble { assemble {

View file

@ -12,7 +12,10 @@ import java.nio.file.attribute.BasicFileAttributes
// com.beust.kobalt.main(argv) // com.beust.kobalt.main(argv)
//} //}
public class LineCountPlugin : BasePlugin(), ITaskContributor { /**
* A simple line counting plug-in for Kobalt.
*/
class LineCountPlugin : BasePlugin(), ITaskContributor {
// ITaskContributor // ITaskContributor
override fun tasksFor(project: Project, context: KobaltContext) = listOf( override fun tasksFor(project: Project, context: KobaltContext) = listOf(
DynamicTask(this, DynamicTask(this,
@ -44,7 +47,7 @@ public class LineCountPlugin : BasePlugin(), ITaskContributor {
val path = Paths.get(it) val path = Paths.get(it)
if (path.toFile().exists()) { if (path.toFile().exists()) {
Files.walkFileTree(path, object : SimpleFileVisitor<Path>() { Files.walkFileTree(path, object : SimpleFileVisitor<Path>() {
override public fun visitFile(path: Path, attrs: BasicFileAttributes): FileVisitResult { override fun visitFile(path: Path, attrs: BasicFileAttributes): FileVisitResult {
if (matcher.matches(path)) { if (matcher.matches(path)) {
fileCount++ fileCount++
lineCount += Files.lines(path).count() lineCount += Files.lines(path).count()
@ -63,7 +66,7 @@ public class LineCountPlugin : BasePlugin(), ITaskContributor {
data class LineCountInfo(var suffix: String = "**kt") data class LineCountInfo(var suffix: String = "**kt")
@Directive @Directive
public fun lineCount(init: LineCountInfo.() -> Unit): LineCountInfo { fun lineCount(init: LineCountInfo.() -> Unit): LineCountInfo {
with(LineCountInfo()) { with(LineCountInfo()) {
init() init()
(Kobalt.findPlugin(LineCountPlugin.NAME) as LineCountPlugin).info = this (Kobalt.findPlugin(LineCountPlugin.NAME) as LineCountPlugin).info = this