mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 00:17:11 -07:00
Multi build work.
This commit is contained in:
parent
33844b616e
commit
350b471460
4 changed files with 40 additions and 22 deletions
|
@ -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()
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.beust.kobalt.internal.build
|
||||
|
||||
import com.beust.kobalt.api.Kobalt
|
||||
import com.beust.kobalt.homeDir
|
||||
import java.io.File
|
||||
import java.nio.file.*
|
||||
|
@ -22,31 +23,33 @@ 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>() {
|
||||
override fun preVisitDirectory(dir: Path?, attrs: BasicFileAttributes?): FileVisitResult {
|
||||
if (dir != null) {
|
||||
val path = dir.toFile()
|
||||
println(path.name)
|
||||
if (path.name == "src" && path.parentFile.name == "kobalt") {
|
||||
val sources = path.listFiles().filter { it.name.endsWith(".kt")}
|
||||
result.addAll(sources)
|
||||
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()
|
||||
if (path.name == "src" && path.parentFile.name == "kobalt") {
|
||||
val sources = path.listFiles().filter { it.name.endsWith(".kt") }.map { it.path }
|
||||
result.addAll(sources)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FileVisitResult.CONTINUE
|
||||
}
|
||||
})
|
||||
return FileVisitResult.CONTINUE
|
||||
}
|
||||
})
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue