mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Temporary hack to fix annotation processing builds.
This commit is contained in:
parent
1b6cbd842c
commit
1c9514ede8
2 changed files with 26 additions and 12 deletions
|
@ -82,7 +82,13 @@ class CompilerUtils @Inject constructor(val files: KFiles,
|
|||
|
||||
// The classpath needs to contain $buildDirectory/classes as well so that projects that contain
|
||||
// multiple languages can use classes compiled by the compiler run before them.
|
||||
if (buildDirectory.exists()) {
|
||||
fun containsClassFiles(dir: File) =
|
||||
KFiles.containsCertainFile(dir) {
|
||||
it.isFile && it.name.endsWith("class")
|
||||
}
|
||||
|
||||
// if (buildDirectory.exists()) {
|
||||
if (containsClassFiles(buildDirectory)) {
|
||||
classpath += FileDependency(buildDirectory.path)
|
||||
}
|
||||
|
||||
|
@ -129,17 +135,9 @@ class CompilerUtils @Inject constructor(val files: KFiles,
|
|||
// is compiler agnostic, doesn't hardcode Kotlin specific stuff
|
||||
val extraSourceFiles = arrayListOf<String>()
|
||||
|
||||
fun containsJavaFiles(dir: File) : Boolean {
|
||||
if (dir.isDirectory) {
|
||||
val directories = arrayListOf<File>()
|
||||
dir.listFiles().forEach {
|
||||
if (it.isFile && it.name.endsWith("java")) return true
|
||||
if (it.isDirectory) directories.add(it)
|
||||
}
|
||||
return directories.any { containsJavaFiles(it) }
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
fun containsJavaFiles(dir: File) =
|
||||
KFiles.containsCertainFile(dir) {
|
||||
it.isFile && it.name.endsWith("java")
|
||||
}
|
||||
|
||||
if (sourceSuffixes.any { it.contains("kt")}) {
|
||||
|
|
|
@ -330,6 +330,22 @@ class KFiles {
|
|||
}
|
||||
|
||||
fun isResource(name: String) = name.contains("res") || name.contains("resources")
|
||||
|
||||
/**
|
||||
* @return true as soon as a file meeting the condition is found.
|
||||
*/
|
||||
fun containsCertainFile(dir: File, condition: (File) -> Boolean) : Boolean {
|
||||
if (dir.isDirectory) {
|
||||
val directories = arrayListOf<File>()
|
||||
dir.listFiles().forEach {
|
||||
if (condition(it)) return true
|
||||
if (it.isDirectory) directories.add(it)
|
||||
}
|
||||
return directories.any { containsCertainFile(it, condition) }
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun findRecursively(directory: File, function: Function1<String, Boolean>): List<String> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue