mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 16:28:12 -07:00
parent
0ad9ed6cb0
commit
152ed057b4
2 changed files with 21 additions and 21 deletions
|
@ -22,32 +22,37 @@ sealed class IFileSpec {
|
||||||
|
|
||||||
constructor(spec: String) : this(arrayListOf(spec))
|
constructor(spec: String) : this(arrayListOf(spec))
|
||||||
|
|
||||||
private fun isIncluded(excludes: List<Glob>, rel: Path) : Boolean {
|
private fun isIncluded(includeMatchers: Glob, excludes: List<Glob>, rel: Path) : Boolean {
|
||||||
excludes.forEach {
|
excludes.forEach {
|
||||||
if (it.matches(rel)) {
|
if (it.matches(rel)) {
|
||||||
log(2, "Excluding ${rel.toFile()}")
|
log(2, "Excluding ${rel.toFile()}")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log(2, "Including ${rel.toFile().absolutePath}")
|
if (includeMatchers.matches(rel)) {
|
||||||
return true
|
log(2, "Including ${rel.toFile().absolutePath}")
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
log(2, "Excluding ${rel.toFile()} (not matching any include pattern")
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toFiles(filePath: String, excludes: List<Glob>): List<File> {
|
override fun toFiles(filePath: String, excludes: List<Glob>): List<File> {
|
||||||
val result = arrayListOf<File>()
|
val result = arrayListOf<File>()
|
||||||
|
val includes = Glob(*spec.toTypedArray())
|
||||||
|
|
||||||
if (File(filePath).isDirectory) {
|
if (File(filePath).isDirectory) {
|
||||||
Files.walkFileTree(Paths.get(filePath), object : SimpleFileVisitor<Path>() {
|
Files.walkFileTree(Paths.get(filePath), object : SimpleFileVisitor<Path>() {
|
||||||
override public fun visitFile(path: Path, attrs: BasicFileAttributes): FileVisitResult {
|
override public fun visitFile(path: Path, attrs: BasicFileAttributes): FileVisitResult {
|
||||||
val rel = Paths.get(filePath).relativize(path)
|
val rel = Paths.get(filePath).relativize(path)
|
||||||
if (isIncluded(excludes, rel)) {
|
if (isIncluded(includes, excludes, rel)) {
|
||||||
result.add(rel.toFile())
|
result.add(rel.toFile())
|
||||||
}
|
}
|
||||||
return FileVisitResult.CONTINUE
|
return FileVisitResult.CONTINUE
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
if (isIncluded(excludes, Paths.get(filePath))) {
|
if (isIncluded(includes, excludes, Paths.get(filePath))) {
|
||||||
result.add(File(filePath))
|
result.add(File(filePath))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -259,7 +259,7 @@ open class JvmCompilerPlugin @Inject constructor(
|
||||||
buildDirectory.mkdirs()
|
buildDirectory.mkdirs()
|
||||||
|
|
||||||
|
|
||||||
val initialSourceDirectories = ArrayList<File>()
|
val initialSourceDirectories = ArrayList<File>(sourceDirectories)
|
||||||
// Source directories from the contributors
|
// Source directories from the contributors
|
||||||
initialSourceDirectories.addAll(
|
initialSourceDirectories.addAll(
|
||||||
if (isTest) {
|
if (isTest) {
|
||||||
|
@ -270,23 +270,18 @@ open class JvmCompilerPlugin @Inject constructor(
|
||||||
|
|
||||||
// Transform them with the interceptors, if any
|
// Transform them with the interceptors, if any
|
||||||
val allSourceDirectories = if (isTest) {
|
val allSourceDirectories = if (isTest) {
|
||||||
initialSourceDirectories
|
initialSourceDirectories
|
||||||
} else {
|
} else {
|
||||||
context.pluginInfo.sourceDirectoriesInterceptors.fold(initialSourceDirectories.toList(),
|
context.pluginInfo.sourceDirectoriesInterceptors.fold(initialSourceDirectories.toList(),
|
||||||
{ sd, interceptor -> interceptor.intercept(project, context, sd) })
|
{ sd, interceptor -> interceptor.intercept(project, context, sd) })
|
||||||
}.filter {
|
}.filter {
|
||||||
File(project.directory, it.path).exists()
|
File(project.directory, it.path).exists()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now that we have all the source directories, find all the source files in them
|
// Now that we have all the source directories, find all the source files in them
|
||||||
|
val sourceFiles = files.findRecursively(projectDirectory, allSourceDirectories,
|
||||||
val sourceFiles = if (allSourceDirectories.size > 0) {
|
{ file -> sourceSuffixes.any { file.endsWith(it) }})
|
||||||
files.findRecursively(projectDirectory, allSourceDirectories,
|
.map { File(projectDirectory, it).path }
|
||||||
{ 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
|
// 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
|
// directory. In this case, also pass that java source directory to the Kotlin compiler as is
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue