[Commonizer][test] Get K/N distribution in the test instead of the build

Get distribution and home path in the test to simplify gradle build.
Using NativeCompilerDownloader in the build led to the undesired results
where test get old K/N compiler from the bootstrap, also blocking K/N
version class development.
This commit is contained in:
Pavel Punegov
2022-04-01 16:04:19 +03:00
committed by Space
parent 38696a41bc
commit cfe76343d5
2 changed files with 28 additions and 68 deletions
@@ -5,10 +5,28 @@
package org.jetbrains.kotlin.commonizer.utils
import org.gradle.api.internal.project.ProjectInternal
import org.gradle.testfixtures.ProjectBuilder
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.dsl.kotlinExtension
import org.jetbrains.kotlin.gradle.utils.NativeCompilerDownloader
import java.io.File
internal val konanHome: File
get() {
val konanHomePath = System.getenv("KONAN_HOME")?.toString() ?: error("Missing KONAN_HOME environment variable")
return File(konanHomePath)
}
internal val konanHome: File by lazy {
val project = ProjectBuilder
.builder()
.build()
?.run {
project.plugins.apply("kotlin-multiplatform")
(project.kotlinExtension as KotlinMultiplatformExtension).apply {
macosX64()
macosArm64()
linuxX64()
mingwX64()
}
this
} as ProjectInternal
project.evaluate()
NativeCompilerDownloader(project).compilerDirectory
}