diff --git a/Build.kt b/Build.kt
index 4a6a908..a2388f9 100644
--- a/Build.kt
+++ b/Build.kt
@@ -2,30 +2,33 @@ import com.beust.kobalt.*
import com.beust.kobalt.plugin.packaging.*
import com.beust.kobalt.plugin.kotlin.*
import com.beust.kobalt.plugin.publish.*
-
-
-val repos = repos("https://dl.bintray.com/cbeust/maven/")
-
-val plugins = plugins(
- "com.beust.kobalt:kobalt-line-count:0.8"
-// file("/Users/beust/kotlin/kobalt-line-count/kobaltBuild/libs/kobalt-line-count-0.6.jar")
-)
-
+//import com.beust.kobalt.plugin.linecount.lineCount
+//
+//val plugins = plugins(
+//// "com.beust.kobalt:kobalt-line-count:0.8"
+//// file(homeDir("kotlin/kobalt-line-count/kobaltBuild/libs/kobalt-line-count-0.8.jar"))
+// file(homeDir("kotlin/kobalt-line-count/kobaltBuild/libs/kobalt-line-count-0.9.jar"))
+//)
+//
+//val lc = lineCount {
+// suffix = "**.md"
+//}
val project = kotlinProject {
name = "kobalt-line-count"
group = "com.beust.kobalt"
artifactId = name
- version = "0.8"
+ version = "0.10"
dependencies {
- compile("com.beust:kobalt:0.154")
+// compile("file:" + homeDir("kotlin/kobalt/kobaltBuild/libs/kobalt-0.168.jar"))
+ compile("com.beust:kobalt:0.170")
}
}
val packProject = assemble(project) {
mavenJars {
manifest {
- attributes("Kobalt-Plugin-Class", "com.beust.kobalt.plugin.linecount.Main")
+ attributes("Kobalt-Plugin-Class", "com.beust.kobalt.plugin.linecount.LineCountMain")
}
}
}
@@ -33,4 +36,3 @@ val packProject = assemble(project) {
val jc = jcenter(project) {
publish = true
}
-
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..3410019
--- /dev/null
+++ b/README.md
@@ -0,0 +1 @@
+# kobalt-line-count, a plug-in for the Kobalt build system
diff --git a/build.gradle b/build.gradle
index 1219bab..bb3585c 100644
--- a/build.gradle
+++ b/build.gradle
@@ -23,7 +23,7 @@ apply plugin: 'kotlin'
dependencies {
compile "com.google.guava:guava:18.0"
- compile "com.beust:kobalt:0.155"
+ compile "com.beust:kobalt:0.170"
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
diff --git a/kobalt-line-count.iml b/kobalt-line-count.iml
index 92c4697..5e19edd 100644
--- a/kobalt-line-count.iml
+++ b/kobalt-line-count.iml
@@ -17,7 +17,6 @@
-
@@ -37,5 +36,6 @@
+
\ No newline at end of file
diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties
index 5554d50..c983ada 100644
--- a/kobalt/wrapper/kobalt-wrapper.properties
+++ b/kobalt/wrapper/kobalt-wrapper.properties
@@ -1 +1 @@
-kobalt.version=0.155
\ No newline at end of file
+kobalt.version=0.170
\ No newline at end of file
diff --git a/src/main/kotlin/com/beust/kobalt/plugin/linecount/LineCountMain.kt b/src/main/kotlin/com/beust/kobalt/plugin/linecount/LineCountMain.kt
new file mode 100644
index 0000000..330d8f0
--- /dev/null
+++ b/src/main/kotlin/com/beust/kobalt/plugin/linecount/LineCountMain.kt
@@ -0,0 +1,70 @@
+package com.beust.kobalt.plugin.linecount
+
+import com.beust.kobalt.Plugins
+import com.beust.kobalt.api.BasePlugin
+import com.beust.kobalt.internal.TaskResult
+import com.beust.kobalt.api.*
+import com.beust.kobalt.api.annotation.Directive
+import com.beust.kobalt.api.annotation.Task
+import com.beust.kobalt.misc.KobaltLogger
+
+import java.nio.file.attribute.BasicFileAttributes
+import java.nio.file.*
+
+fun main(argv: Array) {
+ com.beust.kobalt.main(argv)
+}
+
+public class LineCountMain : BasePlugin(), KobaltLogger {
+ companion object {
+ const val NAME : String = "kobalt-line-count"
+ }
+ override val name = NAME
+
+ 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", wrapAfter = arrayListOf("compile")) {
+ println("DYNAMIC")
+ TaskResult()
+ }
+ }
+
+ @Task(name = "lineCount", description = "Count the lines", runBefore = arrayOf("compile"))
+ fun lineCount(project: Project): TaskResult {
+
+ var fileCount = 0
+ var lineCount : Long = 0
+ log(1, "Finding files that end in ${info.suffix}")
+ val matcher = FileSystems.getDefault().getPathMatcher("glob:" + info.suffix)
+ val path = Paths.get(project.directory)
+ if (path.toFile().exists()) {
+ Files.walkFileTree(path, 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 $path")
+ }
+ return FileVisitResult.CONTINUE
+ }
+ })
+ }
+ log(1, "Found $lineCount lines in $fileCount files")
+ return TaskResult()
+ }
+}
+
+data class LineCountInfo(var suffix: String = "**kt")
+
+@Directive
+public fun lineCount(init: LineCountInfo.() -> Unit): LineCountInfo {
+ with(LineCountInfo()) {
+ init()
+ (Plugins.getPlugin(LineCountMain.NAME) as LineCountMain).info = this
+ return this
+ }
+}
diff --git a/src/main/kotlin/com/beust/kobalt/plugin/linecount/Main.kt b/src/main/kotlin/com/beust/kobalt/plugin/linecount/Main.kt
deleted file mode 100644
index a7ee0a1..0000000
--- a/src/main/kotlin/com/beust/kobalt/plugin/linecount/Main.kt
+++ /dev/null
@@ -1,48 +0,0 @@
-package com.beust.kobalt.plugin.linecount
-
-import com.beust.kobalt.api.BasePlugin
-import com.beust.kobalt.internal.TaskResult
-import com.beust.kobalt.api.*
-import com.beust.kobalt.api.annotation.Task
-import com.beust.kobalt.misc.KobaltLogger
-
-import java.nio.file.attribute.BasicFileAttributes
-import java.nio.file.*
-
-fun main(argv: Array) {
- com.beust.kobalt.main(argv)
-}
-
-public class Main : BasePlugin(), KobaltLogger {
- override val name = "kobalt-line-count"
-
- override fun apply(project: Project, context: KobaltContext) {
- 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 {
- val path = Paths.get(it)
- if (path.toFile().exists()) {
- Files.walkFileTree(path, 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()
- }
-}