diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/compilationImpl/KotlinCompilationFriendPathsResolver.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/compilationImpl/KotlinCompilationFriendPathsResolver.kt index ba2892bc8b31d..67d3f922d0aaf 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/compilationImpl/KotlinCompilationFriendPathsResolver.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/compilationImpl/KotlinCompilationFriendPathsResolver.kt @@ -25,17 +25,17 @@ internal class DefaultKotlinCompilationFriendPathsResolver( override fun resolveFriendPaths(compilation: InternalKotlinCompilation<*>): Iterable { return mutableListOf().apply { - compilation.allAssociatedCompilations.forEach { - add(it.output.classesDirs) + val friendsFromAssociatedCompilations = compilation.project.files() + compilation.allAssociatedCompilations.forAll { + friendsFromAssociatedCompilations.from(it.output.classesDirs) // Adding classes that could be produced to non-default destination for JVM target // Check KotlinSourceSetProcessor for details @Suppress("UNCHECKED_CAST") - add( - compilation.project.files( - (it.compileTaskProvider as TaskProvider).flatMap { task -> task.destinationDirectory } - ) - ) + val compileTaskOutput = (it.compileTaskProvider as TaskProvider) + .flatMap { task -> task.destinationDirectory } + friendsFromAssociatedCompilations.from(compileTaskOutput) } + add(friendsFromAssociatedCompilations) add(friendArtifactResolver.resolveFriendArtifacts(compilation)) } }