mirror of
https://github.com/ethauvin/kobalt-line-count.git
synced 2025-04-25 03:07:11 -07:00
Initial commit
This commit is contained in:
commit
26a16c6a55
6 changed files with 128 additions and 0 deletions
37
Build.kt
Normal file
37
Build.kt
Normal file
|
@ -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")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
48
kobalt-line-count.iml
Normal file
48
kobalt-line-count.iml
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module external.linked.project.id="kobalt-line-count" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
|
||||||
|
<component name="FacetManager">
|
||||||
|
<facet type="java-gradle" name="Java-Gradle">
|
||||||
|
<configuration>
|
||||||
|
<option name="BUILD_FOLDER_PATH" />
|
||||||
|
</configuration>
|
||||||
|
</facet>
|
||||||
|
</component>
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="false">
|
||||||
|
<output url="file://$MODULE_DIR$/build/classes/main" />
|
||||||
|
<output-test url="file://$MODULE_DIR$/build/classes/test" />
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/kotlin" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/test/kotlin" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib:0.13.1513" level="project" />
|
||||||
|
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-compiler-embeddable:0.13.1513" level="project" />
|
||||||
|
<orderEntry type="library" name="Gradle: com.beust:kobalt:0.71" level="project" />
|
||||||
|
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-runtime:0.13.1513" level="project" />
|
||||||
|
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-compiler:0.13.1513" level="project" />
|
||||||
|
<orderEntry type="library" name="Gradle: com.beust:jcommander:1.48" level="project" />
|
||||||
|
<orderEntry type="library" name="Gradle: com.beust:klaxon:0.14" level="project" />
|
||||||
|
<orderEntry type="library" name="Gradle: com.squareup.okhttp:okhttp:2.4.0" level="project" />
|
||||||
|
<orderEntry type="library" name="Gradle: org.slf4j:slf4j-api:1.7.12" level="project" />
|
||||||
|
<orderEntry type="library" name="Gradle: org.slf4j:slf4j-simple:1.7.12" level="project" />
|
||||||
|
<orderEntry type="library" name="Gradle: ch.qos.logback:logback-classic:1.1.2" level="project" />
|
||||||
|
<orderEntry type="library" name="Gradle: org.jsoup:jsoup:1.8.2" level="project" />
|
||||||
|
<orderEntry type="library" name="Gradle: com.google.inject:guice:4.0" level="project" />
|
||||||
|
<orderEntry type="library" name="Gradle: com.google.inject.extensions:guice-assistedinject:4.0" level="project" />
|
||||||
|
<orderEntry type="library" name="Gradle: com.google.guava:guava:18.0" level="project" />
|
||||||
|
<orderEntry type="library" name="Gradle: org.apache.maven:maven-model:3.3.3" level="project" />
|
||||||
|
<orderEntry type="library" name="Gradle: com.squareup.okio:okio:1.4.0" level="project" />
|
||||||
|
<orderEntry type="library" name="Gradle: ch.qos.logback:logback-core:1.1.2" level="project" />
|
||||||
|
<orderEntry type="library" name="Gradle: javax.inject:javax.inject:1" level="project" />
|
||||||
|
<orderEntry type="library" name="Gradle: aopalliance:aopalliance:1.0" level="project" />
|
||||||
|
<orderEntry type="library" name="Gradle: org.codehaus.plexus:plexus-utils:3.0.20" level="project" />
|
||||||
|
</component>
|
||||||
|
</module>
|
BIN
kobalt/wrapper/kobalt-wrapper.jar
Normal file
BIN
kobalt/wrapper/kobalt-wrapper.jar
Normal file
Binary file not shown.
1
kobalt/wrapper/kobalt-wrapper.properties
Normal file
1
kobalt/wrapper/kobalt-wrapper.properties
Normal file
|
@ -0,0 +1 @@
|
||||||
|
kobalt.version=0.71
|
1
kobaltw
Executable file
1
kobaltw
Executable file
|
@ -0,0 +1 @@
|
||||||
|
java -jar kobalt/wrapper/kobalt-wrapper.jar $*
|
41
src/main/kotlin/com/beust/kobalt/plugin/linecount/Main.kt
Normal file
41
src/main/kotlin/com/beust/kobalt/plugin/linecount/Main.kt
Normal file
|
@ -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<Path>() {
|
||||||
|
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()
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue