commit 26a16c6a5524f204104eee9a888b6e5db3eb7144 Author: Cedric Beust Date: Sat Sep 26 22:14:54 2015 -0700 Initial commit diff --git a/Build.kt b/Build.kt new file mode 100644 index 0000000..30ad064 --- /dev/null +++ b/Build.kt @@ -0,0 +1,37 @@ +import com.beust.kobalt.* +import com.beust.kobalt.plugin.packaging.packaging +import com.beust.kobalt.plugin.kotlin.* + +val repos = repos("https://dl.bintray.com/cbeust/maven/") + +val project = kotlinProject { + name = "kobalt-line-count" + group = "com.beust.kobalt" + artifactId = name + version = "0.2" + directory = "/Users/beust/kotlin/kobalt-line-count" + + sourceDirectories { + path("src/main/kotlin") + } + + sourceDirectoriesTest { + path() + } + + dependencies { + compile("com.beust:kobalt:0.71") + } + +// dependenciesTest { +// compile("org.testng:testng:6.9.5") +// } +} + +val packProject = packaging(project) { + jar { + manifest { + attributes("Kobalt-Plugin-Class", "com.beust.kobalt.plugin.linecount.Main") + } + } +} diff --git a/kobalt-line-count.iml b/kobalt-line-count.iml new file mode 100644 index 0000000..76bee44 --- /dev/null +++ b/kobalt-line-count.iml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/kobalt/wrapper/kobalt-wrapper.jar b/kobalt/wrapper/kobalt-wrapper.jar new file mode 100644 index 0000000..db1202f Binary files /dev/null and b/kobalt/wrapper/kobalt-wrapper.jar differ diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties new file mode 100644 index 0000000..c8812a5 --- /dev/null +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -0,0 +1 @@ +kobalt.version=0.71 \ No newline at end of file diff --git a/kobaltw b/kobaltw new file mode 100755 index 0000000..7921741 --- /dev/null +++ b/kobaltw @@ -0,0 +1 @@ +java -jar kobalt/wrapper/kobalt-wrapper.jar $* diff --git a/src/main/kotlin/com/beust/kobalt/plugin/linecount/Main.kt b/src/main/kotlin/com/beust/kobalt/plugin/linecount/Main.kt new file mode 100644 index 0000000..7cbd367 --- /dev/null +++ b/src/main/kotlin/com/beust/kobalt/plugin/linecount/Main.kt @@ -0,0 +1,41 @@ +package com.beust.kobalt.plugin.linecount + +import com.beust.kobalt.api.BasePlugin +import com.beust.kobalt.internal.TaskResult +import java.nio.file.attribute.BasicFileAttributes + +import com.beust.kobalt.api.Project +import com.beust.kobalt.api.annotation.Task +import com.beust.kobalt.misc.KobaltLogger +import java.nio.file.* + +public class Main : BasePlugin(), KobaltLogger { + override val name = "kobalt-line-count" + + override fun apply(project: Project) { + println("*** Applying plugin ${name} with project ${project}") + } + + @Task(name = "lineCount", description = "Count the lines", runBefore = arrayOf("compile")) + fun lineCount(project: Project): TaskResult { + + var fileCount = 0 + var lineCount : Long = 0 + val matcher = FileSystems.getDefault().getPathMatcher("glob:**.kt") + project.sourceDirectories.forEach { + Files.walkFileTree(Paths.get(it), object: SimpleFileVisitor() { + override public fun visitFile(path: Path, attrs: BasicFileAttributes): FileVisitResult { + log(2, "File: ${path}") + if (matcher.matches(path)) { + fileCount++ + lineCount += Files.lines(path).count() + log(2, " MATCH") + } + return FileVisitResult.CONTINUE + } + }) + } + log(1, "Found ${lineCount} lines in ${fileCount} files") + return TaskResult() + } +}