[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:
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user