1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 00:17:11 -07:00

Merge with beust/kobalt.

This commit is contained in:
Erik C. Thauvin 2017-03-28 17:25:47 -07:00
commit d605b4a132
4 changed files with 31 additions and 13 deletions

View file

@ -31,6 +31,10 @@ class BuildScriptConfig {
@Directive
fun kobaltOptions(vararg options: String) = Kobalt.addKobaltOptions(options)
/** Where to find additional build files */
@Directive
fun buildSourceDirs(vararg dirs: String) = Kobalt.addBuildSourceDirs(dirs)
// The following settings modify the compiler used to compile the build file, which regular users should
// probably never need to do. Projects should use kotlinCompiler { compilerVersion } to configure the
// Kotin compiler for their source files.
@ -127,4 +131,3 @@ fun localMaven() : String {
}
return result.toURI().toString()
}

View file

@ -120,9 +120,13 @@ class Kobalt {
fun findPlugin(name: String) = Plugins.findPlugin(name)
val optionsFromBuild = arrayListOf<String>()
fun addKobaltOptions(options: Array<out String>) {
optionsFromBuild.addAll(options)
}
val buildSourceDirs = arrayListOf<String>()
fun addBuildSourceDirs(dirs: Array<out String>) {
buildSourceDirs.addAll(dirs)
}
}
}

View file

@ -1,5 +1,6 @@
package com.beust.kobalt.internal.build
import com.beust.kobalt.api.Kobalt
import com.beust.kobalt.homeDir
import com.beust.kobalt.misc.kobaltLog
import java.io.File
@ -23,24 +24,25 @@ class BuildSources(val file: File) : IBuildSources {
override val root = file
override fun findSourceFiles() : List<File> {
return listOf(/* "kobalt/src/a.kt", */ "kobalt/src/Build.kt")
.map(::File)
// .map { BuildFile(Paths.get(it), it)}
val result = arrayListOf("kobalt/src/Build.kt")
if (Kobalt.buildSourceDirs.isNotEmpty()) result.addAll(findBuildFiles(Kobalt.buildSourceDirs))
return result.map(::File)
}
override fun exists() = findSourceFiles().isNotEmpty()
override fun toString() = "{BuildSources " + findSourceFiles()[0] + "...}"
override fun toString() = "{BuildSources " + findSourceFiles().joinToString(", ") + "}"
fun _findSourceFiles() : List<File> {
val result = arrayListOf<File>()
Files.walkFileTree(Paths.get(file.absolutePath), object : SimpleFileVisitor<Path>() {
fun findBuildFiles(roots: List<String>) : List<String> {
val result = arrayListOf<String>()
roots.forEach { file ->
Files.walkFileTree(Paths.get(file), object : SimpleFileVisitor<Path>() {
override fun preVisitDirectory(dir: Path?, attrs: BasicFileAttributes?): FileVisitResult {
if (dir != null) {
val path = dir.toFile()
kobaltLog(1, path.name)
if (path.name == "src" && path.parentFile.name == "kobalt") {
val sources = path.listFiles().filter { it.name.endsWith(".kt")}
val sources = path.listFiles().filter { it.name.endsWith(".kt") }.map { it.path }
result.addAll(sources)
}
}
@ -48,6 +50,7 @@ class BuildSources(val file: File) : IBuildSources {
return FileVisitResult.CONTINUE
}
})
}
return result
}
}