[Gradle] Added provisioned.ok after k/n bundle installation

Added provisioned.ok file to ensure
that Kotlin Native bundle has been successfully installed.

^KT-66309 Fixed
This commit is contained in:
Dmitrii Krasnov
2024-03-04 13:06:48 +01:00
committed by Space Team
parent e72bac333f
commit ffef1630dd
3 changed files with 39 additions and 6 deletions
@@ -1,7 +1,5 @@
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
import org.jetbrains.kotlin.konan.target.HostManager
import org.jetbrains.kotlin.konan.target.KonanTarget
import java.nio.file.Paths
plugins {
@@ -150,11 +148,38 @@ tasks.register<Task>("prepareNativeBundleForGradleIT") {
description = "This task adds dependency on :kotlin-native:bundle"
if (project.kotlinBuildProperties.isKotlinNativeEnabled) {
// 1. Build full Kotlin Native bundle
// Build full Kotlin Native bundle
dependsOn(":kotlin-native:bundle")
}
}
tasks.register<Task>("createProvisionedOkFiles") {
description = "This task creates `provisioned.ok` file for each preconfigured k/n native bundle." +
"Kotlin/Native bundle can be prepared in two ways:" +
"`prepareNativeBundleForGradleIT` task for local environment and `Compiler Dist: full bundle` build for CI environment."
val prepareNativeBundleTaskName = ":kotlin-gradle-plugin-integration-tests:prepareNativeBundleForGradleIT"
val taskExists = project.tasks.findByPath(prepareNativeBundleTaskName) != null
if (taskExists) {
mustRunAfter(prepareNativeBundleTaskName)
}
val konanDistributions = File(konanDataDir)
doLast {
konanDistributions
.walkTopDown().maxDepth(1)
.filter { file -> file != konanDistributions }
.filter { file -> file.isDirectory }
.toSet()
.forEach {
File(it, "provisioned.ok").createNewFile()
}
}
}
fun Test.includeMppAndAndroid(include: Boolean) = includeTestsWithPattern(include) {
addAll(listOf("*Multiplatform*", "*Mpp*", "*Android*"))
}
@@ -164,7 +189,8 @@ fun Test.includeNative(include: Boolean) = includeTestsWithPattern(include) {
}
fun Test.applyKotlinNativeFromCurrentBranchIfNeeded() {
val kotlinNativeFromMasterEnabled = project.kotlinBuildProperties.isKotlinNativeEnabled && project.kotlinBuildProperties.useKotlinNativeLocalDistributionForTests
val kotlinNativeFromMasterEnabled =
project.kotlinBuildProperties.isKotlinNativeEnabled && project.kotlinBuildProperties.useKotlinNativeLocalDistributionForTests
//add native bundle dependencies for local test run
if (kotlinNativeFromMasterEnabled && !project.kotlinBuildProperties.isTeamcityBuild) {
@@ -185,6 +211,7 @@ fun Test.applyKotlinNativeFromCurrentBranchIfNeeded() {
}
systemProperty("konanDataDirForIntegrationTests", konanDataDir)
}
dependsOn(":kotlin-gradle-plugin-integration-tests:createProvisionedOkFiles")
}
fun Test.includeTestsWithPattern(include: Boolean, patterns: (MutableSet<String>).() -> Unit) {
@@ -77,6 +77,7 @@ class KotlinNativeCompilerDownloadIT : KGPBaseTest() {
assertOutputDoesNotContain(DOWNLOAD_KONAN_FINISHED_LOG)
assertOutputContains(UNPUCK_KONAN_FINISHED_LOG)
assertOutputDoesNotContain("Please wait while Kotlin/Native")
assertFileExists(konanTemp.resolve(STABLE_VERSION_DIR_NAME).resolve("provisioned.ok"))
}
}
}
@@ -40,7 +40,7 @@ import java.nio.file.attribute.PosixFilePermission
import java.util.zip.GZIPInputStream
import javax.inject.Inject
private const val KONAN_DIRECTORY_NAME_TO_CHECK_EXISTENCE = "konan"
private const val MARKER_FILE = "provisioned.ok"
internal interface UsesKotlinNativeBundleBuildService : Task {
@get:Internal
@@ -106,7 +106,7 @@ internal abstract class KotlinNativeBundleBuildService : BuildService<BuildServi
removeBundleIfNeeded(reinstallFlag || needToReinstall, bundleDir)
if (!bundleDir.resolve(KONAN_DIRECTORY_NAME_TO_CHECK_EXISTENCE).exists()) {
if (!bundleDir.resolve(MARKER_FILE).exists()) {
val gradleCachesKotlinNativeDir =
resolveKotlinNativeConfiguration(kotlinNativeVersion, kotlinNativeBundleConfiguration)
@@ -115,6 +115,7 @@ internal abstract class KotlinNativeBundleBuildService : BuildService<BuildServi
it.from(gradleCachesKotlinNativeDir)
it.into(bundleDir)
}
createSuccessfulInstallationFile(bundleDir)
project.logger.info("Moved Kotlin/Native bundle from $gradleCachesKotlinNativeDir to ${bundleDir.absolutePath}")
}
}
@@ -250,4 +251,8 @@ internal abstract class KotlinNativeBundleBuildService : BuildService<BuildServi
}
}
}
private fun createSuccessfulInstallationFile(bundleDir: File) {
bundleDir.resolve(MARKER_FILE).createNewFile()
}
}