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

Fix the source includes.

This commit is contained in:
Cedric Beust 2016-02-17 06:51:52 -08:00
parent e824d7dbbf
commit 14cb546dd7
3 changed files with 49 additions and 22 deletions

View file

@ -22,37 +22,32 @@ sealed class IFileSpec {
constructor(spec: String) : this(arrayListOf(spec))
private fun isIncluded(includeMatchers: Glob, excludes: List<Glob>, rel: Path) : Boolean {
private fun isIncluded(excludes: List<Glob>, rel: Path) : Boolean {
excludes.forEach {
if (it.matches(rel)) {
log(2, "Excluding ${rel.toFile()}")
return false
}
}
if (includeMatchers.matches(rel)) {
log(2, "Including ${rel.toFile().absolutePath}")
return true
}
log(2, "Excluding ${rel.toFile()} (not matching any include pattern")
return false
log(2, "Including ${rel.toFile().absolutePath}")
return true
}
override fun toFiles(filePath: String, excludes: List<Glob>): List<File> {
val result = arrayListOf<File>()
val includes = Glob(*spec.toTypedArray())
if (File(filePath).isDirectory) {
Files.walkFileTree(Paths.get(filePath), object : SimpleFileVisitor<Path>() {
override public fun visitFile(path: Path, attrs: BasicFileAttributes): FileVisitResult {
val rel = Paths.get(filePath).relativize(path)
if (isIncluded(includes, excludes, rel)) {
if (isIncluded(excludes, rel)) {
result.add(rel.toFile())
}
return FileVisitResult.CONTINUE
}
})
} else {
if (isIncluded(includes, excludes, Paths.get(filePath))) {
if (isIncluded(excludes, Paths.get(filePath))) {
result.add(File(filePath))
}
}

View file

@ -259,7 +259,7 @@ open class JvmCompilerPlugin @Inject constructor(
buildDirectory.mkdirs()
val initialSourceDirectories = ArrayList<File>(sourceDirectories)
val initialSourceDirectories = ArrayList<File>()
// Source directories from the contributors
initialSourceDirectories.addAll(
if (isTest) {
@ -279,9 +279,13 @@ open class JvmCompilerPlugin @Inject constructor(
}
// Now that we have all the source directories, find all the source files in them
val sourceFiles = files.findRecursively(projectDirectory, allSourceDirectories,
{ file -> sourceSuffixes.any { file.endsWith(it) }})
.map { File(projectDirectory, it).path }
val sourceFiles = if (allSourceDirectories.size > 0) {
files.findRecursively(projectDirectory, allSourceDirectories,
{ file -> sourceSuffixes.any { file.endsWith(it) } })
.map { File(projectDirectory, it).path }
} else {
emptyList()
}
// Special treatment if we are compiling Kotlin files and the project also has a java source
// directory. In this case, also pass that java source directory to the Kotlin compiler as is