mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 16:28:12 -07:00
More test resource fixes.
This commit is contained in:
parent
345dd8440c
commit
c7a094040d
4 changed files with 32 additions and 11 deletions
|
@ -48,7 +48,7 @@ class Variant(val initialProductFlavor: ProductFlavorConfig? = null,
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return result.toList()
|
return result.filter { ! KFiles.isResource(it.path) }.toList()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,7 +56,7 @@ class Variant(val initialProductFlavor: ProductFlavorConfig? = null,
|
||||||
*/
|
*/
|
||||||
fun resourceDirectories(project: Project, sourceSet: SourceSet = SourceSet.MAIN)
|
fun resourceDirectories(project: Project, sourceSet: SourceSet = SourceSet.MAIN)
|
||||||
= sourceDirectories(project, "resources", variantFirst = false, sourceSet = sourceSet)
|
= sourceDirectories(project, "resources", variantFirst = false, sourceSet = sourceSet)
|
||||||
.filter { it.path.contains("resources") || it.path.contains("res") }
|
.filter { KFiles.isResource(it.path) }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* suffix is either "java" (to find source files) or "resources" (to find resources).
|
* suffix is either "java" (to find source files) or "resources" (to find resources).
|
||||||
|
|
|
@ -9,3 +9,10 @@ interface ITestSourceDirectoryContributor {
|
||||||
fun testSourceDirectoriesFor(project: Project, context: KobaltContext): List<File>
|
fun testSourceDirectoriesFor(project: Project, context: KobaltContext): List<File>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun KobaltContext.testSourceDirectories(project: Project) : List<File> {
|
||||||
|
val result = pluginInfo.testSourceDirContributors.flatMap {
|
||||||
|
it.testSourceDirectoriesFor(project, this)
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -174,8 +174,14 @@ open class JvmCompilerPlugin @Inject constructor(
|
||||||
} else {
|
} else {
|
||||||
compilerContributors.forEach { contributor ->
|
compilerContributors.forEach { contributor ->
|
||||||
contributor.compilersFor(project, context).forEach { compiler ->
|
contributor.compilersFor(project, context).forEach { compiler ->
|
||||||
|
val contributedSourceDirs =
|
||||||
|
if (isTest) {
|
||||||
|
context.testSourceDirectories(project)
|
||||||
|
} else {
|
||||||
|
context.sourceDirectories(project)
|
||||||
|
}
|
||||||
val sourceFiles = KFiles.findSourceFiles(project.directory,
|
val sourceFiles = KFiles.findSourceFiles(project.directory,
|
||||||
context.sourceDirectories(project).map { it.path }, compiler.sourceSuffixes)
|
contributedSourceDirs.map { it.path }, compiler.sourceSuffixes)
|
||||||
if (sourceFiles.size > 0) {
|
if (sourceFiles.size > 0) {
|
||||||
// TODO: createCompilerActionInfo recalculates the source files, only compute them
|
// TODO: createCompilerActionInfo recalculates the source files, only compute them
|
||||||
// once and pass them
|
// once and pass them
|
||||||
|
@ -268,15 +274,21 @@ 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 =
|
||||||
initialSourceDirectories
|
if (isTest) {
|
||||||
} else {
|
initialSourceDirectories
|
||||||
context.pluginInfo.sourceDirectoriesInterceptors.fold(initialSourceDirectories.toList(),
|
} else {
|
||||||
{ sd, interceptor -> interceptor.intercept(project, context, sd) })
|
context.pluginInfo.sourceDirectoriesInterceptors.fold(initialSourceDirectories.toList(),
|
||||||
}.filter {
|
{ sd, interceptor -> interceptor.intercept(project, context, sd) })
|
||||||
File(project.directory, it.path).exists()
|
}.filter {
|
||||||
}
|
File(project.directory, it.path).exists()
|
||||||
|
}.filter {
|
||||||
|
! KFiles.isResource(it.path)
|
||||||
|
}.distinct()
|
||||||
|
|
||||||
|
if (allSourceDirectories.any { KFiles.isResource(it.path) }) {
|
||||||
|
println("PROBLEM")
|
||||||
|
}
|
||||||
// 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 = files.findRecursively(projectDirectory, allSourceDirectories,
|
||||||
{ file -> sourceSuffixes.any { file.endsWith(it) }})
|
{ file -> sourceSuffixes.any { file.endsWith(it) }})
|
||||||
|
|
|
@ -310,6 +310,8 @@ class KFiles {
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun isResource(name: String) = name.contains("res") || name.contains("resources")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun findRecursively(directory: File, function: Function1<String, Boolean>): List<String> {
|
fun findRecursively(directory: File, function: Function1<String, Boolean>): List<String> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue