Skip to content

Commit 298fdaf

Browse files
Abduqodiri Qurbonzodaqurbonzoda
Abduqodiri Qurbonzoda
authored andcommitted
Forward the kotlin.native.version parameter to test projects
1 parent 9ab3ea4 commit 298fdaf

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

buildSrc/src/main/kotlin/KotlinCommunity.kt

+13
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,16 @@ fun getOverriddenKotlinLanguageVersion(project: Project): String? {
6363
}
6464
return languageVersion
6565
}
66+
67+
/**
68+
* Should be used for running against non-released Kotlin compiler on a system test level.
69+
*
70+
* @return a Kotlin API version parametrized from command line or gradle.properties, null otherwise
71+
*/
72+
fun getOverriddenKotlinNativeVersion(project: Project): String? {
73+
val nativeVersion = project.providers.gradleProperty("kotlin.native.version").orNull
74+
if (!nativeVersion.isNullOrBlank()) {
75+
project.logger.info("""Configured Kotlin Native distribution version: '$nativeVersion' for project ${project.name}""")
76+
}
77+
return nativeVersion
78+
}

integration/build.gradle.kts

+3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ tasks.test {
3333
getOverriddenKotlinApiVersion(project)?.let {
3434
systemProperty("kotlin_api_version", it)
3535
}
36+
getOverriddenKotlinNativeVersion(project)?.let {
37+
systemProperty("kotlin.native.version", it)
38+
}
3639
systemProperty("minSupportedGradleVersion", libs.versions.minSupportedGradle.get())
3740
systemProperty("minSupportedKotlinVersion", libs.versions.minSupportedKotlin.get())
3841
}

integration/src/main/kotlin/kotlinx/benchmark/integration/Runner.kt

+6-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Runner(
1616
private fun gradle(vararg tasks: String): GradleRunner =
1717
GradleRunner.create()
1818
.withProjectDir(projectDir)
19-
.withArguments(*(defaultArguments() + tasks))
19+
.withArguments(*(defaultArguments() + kotlinNativeVersion + tasks))
2020
.withGradleVersion(gradleVersion.versionString)
2121
.forwardStdError(System.err.bufferedWriter())
2222
.run {
@@ -44,6 +44,11 @@ class Runner(
4444

4545
private fun defaultArguments(): Array<String> = arrayOf("--stacktrace")
4646

47+
// Forward the Kotlin Native distribution version to test projects
48+
private val kotlinNativeVersion = "kotlin.native.version".let { property ->
49+
System.getProperty(property)?.let { arrayOf("-P$property=$it") } ?: emptyArray()
50+
}
51+
4752
fun updateAnnotations(filePath: String, annotationsSpecifier: AnnotationsSpecifier.() -> Unit) {
4853
val annotations = AnnotationsSpecifier().also(annotationsSpecifier)
4954
val file = projectDir.resolve(filePath)

0 commit comments

Comments
 (0)