Skip to content

Commit 4196898

Browse files
h0tk3ySokolovaMaria
authored andcommitted
Add the original classesDirs to the friend paths of test compilations
The Kotlin Gradle plugin 1.3.60 has changed how friend paths are determined for the test compilations. Earlier versions used to take the main's compile task destinationDir as the friend paths, but in 1.3.60, there's a new mechanism that work on compilation level. According to it, the test compilation considers the main's output.classesDirs as its friend paths. The atomicfu-gradle-plugin modifies both the main compilation's output.classesDirs and the test compilation's classpath, so that they point to different locations. This caused internal visibility issues with Kotlin 1.3.60. To fix this, add the main's original classesDirs to the test freeCompilerArgs as -Xfriend-paths to ensure that internals are visible in the main's original classes.
1 parent 74e426b commit 4196898

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

atomicfu-gradle-plugin/src/main/kotlin/kotlinx/atomicfu/plugin/gradle/AtomicFUGradlePlugin.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,10 @@ fun Project.configureMultiplatformPluginTasks() {
211211

212212
(tasks.findByName("${target.name}${compilation.name.capitalize()}") as? Test)?.classpath =
213213
originalMainClassesDirs + (compilation as KotlinCompilationToRunnableFiles).runtimeDependencyFiles - mainCompilation.output.classesDirs
214+
215+
compilation.compileKotlinTask.doFirst {
216+
compilation.kotlinOptions.freeCompilerArgs += "-Xfriend-paths=${originalMainClassesDirs.asPath}"
217+
}
214218
}
215219
}
216220
}

0 commit comments

Comments
 (0)