[Gradle] Fix switching in-process to Native embeddable compiler jar

Compiler runner used incorrect cache key for isolated classloader:
it didn't take the actually used compiler jar into account,
only the K/N home dir.

Fix this by using the entire classpath as a key.
This commit is contained in:
Svyatoslav Scherbina
2021-08-28 01:15:52 +03:00
committed by Space
parent 1c052ad448
commit e65f2e465e
2 changed files with 25 additions and 1 deletions
@@ -55,4 +55,25 @@ class NativeEmbeddableCompilerJarIT : BaseGradleIT() {
}
}
}
@Test
fun testSwitch() = with(transformNativeTestProjectWithPluginDsl("executables", directoryPrefix = "native-binaries")) {
build(":runDebugExecutableHost") {
assertSuccessful()
checkNativeCompilerClasspath(":linkDebugExecutableHost", ":compileKotlinHost") {
assertTrue(it.includesRegularJar())
assertFalse(it.includesEmbeddableJar())
}
}
build(":clean") {} // Ensure the tasks aren't up-to-date.
build(":runDebugExecutableHost", "-Pkotlin.native.useEmbeddableCompilerJar=true") {
assertSuccessful()
checkNativeCompilerClasspath(":linkDebugExecutableHost", ":compileKotlinHost") {
assertFalse(it.includesRegularJar())
assertTrue(it.includesEmbeddableJar())
}
}
}
}
@@ -99,7 +99,10 @@ internal abstract class KotlinNativeToolRunner(
""".trimIndent()
}
final override val isolatedClassLoaderCacheKey get() = project.konanHome
data class IsolatedClassLoaderCacheKey(val classpath: Set<java.io.File>)
// TODO: can't we use this for other implementations too?
final override val isolatedClassLoaderCacheKey get() = IsolatedClassLoaderCacheKey(classpath)
override fun transformArgs(args: List<String>) = listOf(toolName) + args