-
Notifications
You must be signed in to change notification settings - Fork 58
Open
Description
I have a variant named "LOCAL_Debug". The val types = variantName.split("(?=\\p{Upper})".toRegex())
will split my varaintName into ["L", "O", "C", "A", "L", "Debug"]. Then the for each
will match many unexcepted files. For example, I use the MacBook. There is a .ds_store
file under app/src
dirs. In this case, the file.list()
casue exception.
Since the varaintName can be various, this is a unstable logic. Looking forward to improvement it.
A problem occurred configuring project ':app'.
> file.list() must not be null
fun findSourcesForVariant(project: Project, variantName: String, language: String): MutableSet<File> {
val possibleDirs: MutableSet<File> = mutableSetOf()
if (project.file("src/main/$language").exists()) {
possibleDirs.add(project.file("src/main/$language"))
}
val types = variantName.split("(?=\\p{Upper})".toRegex())
val root = project.file("src").listFiles()
root.forEach { file ->
types.forEach { type ->
if (file.name.contains(type.toLowerCase()) &&
file.list().any { it.contains(language) }) {
possibleDirs.add(File(file, language))
}
}
}
return LinkedHashSet(possibleDirs)
}
Metadata
Metadata
Assignees
Labels
No labels