diff --git a/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/main.kt b/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/main.kt index 6263d06a082..32ec394756c 100644 --- a/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/main.kt +++ b/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/main.kt @@ -247,15 +247,22 @@ private fun findFilesByGlobs(roots: List, globs: List): Map - // TODO: don't scan the entire tree, skip subdirectories according to globs. - Files.walk(root, FileVisitOption.FOLLOW_LINKS).forEach { path -> - val relativePath = root.relativize(path) - if (!Files.isDirectory(path) && pathMatchers.any { it.matches(relativePath) }) { - relativeToRoot[relativePath] = root + roots.reversed() + .filter { path -> + return@filter when { + path.toFile().exists() -> true + else -> { warn("$path doesn't exist"); false } + } + } + .forEach { root -> + // TODO: don't scan the entire tree, skip subdirectories according to globs. + Files.walk(root, FileVisitOption.FOLLOW_LINKS).forEach { path -> + val relativePath = root.relativize(path) + if (!Files.isDirectory(path) && pathMatchers.any { it.matches(relativePath) }) { + relativeToRoot[relativePath] = root + } + } } - } - } return relativeToRoot }