Skip to content

Commit

Permalink
Forward the kotlin.native.version parameter to test projects
Browse files Browse the repository at this point in the history
  • Loading branch information
qurbonzoda committed Oct 2, 2024
1 parent 9ab3ea4 commit 298fdaf
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
13 changes: 13 additions & 0 deletions buildSrc/src/main/kotlin/KotlinCommunity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,16 @@ fun getOverriddenKotlinLanguageVersion(project: Project): String? {
}
return languageVersion
}

/**
* Should be used for running against non-released Kotlin compiler on a system test level.
*
* @return a Kotlin API version parametrized from command line or gradle.properties, null otherwise
*/
fun getOverriddenKotlinNativeVersion(project: Project): String? {
val nativeVersion = project.providers.gradleProperty("kotlin.native.version").orNull
if (!nativeVersion.isNullOrBlank()) {
project.logger.info("""Configured Kotlin Native distribution version: '$nativeVersion' for project ${project.name}""")
}
return nativeVersion
}
3 changes: 3 additions & 0 deletions integration/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ tasks.test {
getOverriddenKotlinApiVersion(project)?.let {
systemProperty("kotlin_api_version", it)
}
getOverriddenKotlinNativeVersion(project)?.let {
systemProperty("kotlin.native.version", it)
}
systemProperty("minSupportedGradleVersion", libs.versions.minSupportedGradle.get())
systemProperty("minSupportedKotlinVersion", libs.versions.minSupportedKotlin.get())
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Runner(
private fun gradle(vararg tasks: String): GradleRunner =
GradleRunner.create()
.withProjectDir(projectDir)
.withArguments(*(defaultArguments() + tasks))
.withArguments(*(defaultArguments() + kotlinNativeVersion + tasks))
.withGradleVersion(gradleVersion.versionString)
.forwardStdError(System.err.bufferedWriter())
.run {
Expand Down Expand Up @@ -44,6 +44,11 @@ class Runner(

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

// Forward the Kotlin Native distribution version to test projects
private val kotlinNativeVersion = "kotlin.native.version".let { property ->
System.getProperty(property)?.let { arrayOf("-P$property=$it") } ?: emptyArray()
}

fun updateAnnotations(filePath: String, annotationsSpecifier: AnnotationsSpecifier.() -> Unit) {
val annotations = AnnotationsSpecifier().also(annotationsSpecifier)
val file = projectDir.resolve(filePath)
Expand Down

0 comments on commit 298fdaf

Please sign in to comment.