From 5ce2a2cbee0e4751c14bbf8d4e0458e54e9454a9 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Fri, 8 Dec 2023 21:44:00 +0100 Subject: [PATCH] Use strongly typed task GenerateProjectStructureMetadata to tweak kpsm.json --- libraries/kotlin.test/build.gradle.kts | 10 +++++----- libraries/stdlib/build.gradle.kts | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/libraries/kotlin.test/build.gradle.kts b/libraries/kotlin.test/build.gradle.kts index 5f867fd0cd7..abd0dbcbfc9 100644 --- a/libraries/kotlin.test/build.gradle.kts +++ b/libraries/kotlin.test/build.gradle.kts @@ -4,6 +4,7 @@ import com.google.gson.JsonObject import org.gradle.api.publish.internal.PublicationInternal import org.gradle.jvm.tasks.Jar import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType +import org.jetbrains.kotlin.gradle.plugin.mpp.GenerateProjectStructureMetadata import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinUsages import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl import plugins.configureDefaultPublishing @@ -281,8 +282,7 @@ tasks { dependsOn(jvmTestTasks) } - val generateProjectStructureMetadata by existing { - val outputFile = file("build/kotlinProjectStructureMetadata/kotlin-project-structure-metadata.json") + val generateProjectStructureMetadata by existing(GenerateProjectStructureMetadata::class) { val outputTestFile = file("kotlin-project-structure-metadata.beforePatch.json") val patchedFile = file("kotlin-project-structure-metadata.json") @@ -295,16 +295,16 @@ tasks { This will fail if the kotlin-project-structure-metadata.json file would change unnoticed (w/o updating our patched file) */ run { - val outputFileText = outputFile.readText().trim() + val outputFileText = resultFile.readText().trim() val expectedFileContent = outputTestFile.readText().trim() if (outputFileText != expectedFileContent) error( - "${outputFile.path} file content does not match expected content\n\n" + + "${resultFile.path} file content does not match expected content\n\n" + "expected:\n\n$expectedFileContent\n\nactual:\n\n$outputFileText" ) } - patchedFile.copyTo(outputFile, overwrite = true) + patchedFile.copyTo(resultFile, overwrite = true) } } } diff --git a/libraries/stdlib/build.gradle.kts b/libraries/stdlib/build.gradle.kts index 8bc87739bc4..e601370d804 100644 --- a/libraries/stdlib/build.gradle.kts +++ b/libraries/stdlib/build.gradle.kts @@ -1,6 +1,7 @@ @file:Suppress("UNUSED_VARIABLE", "NAME_SHADOWING") import org.gradle.jvm.tasks.Jar import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType +import org.jetbrains.kotlin.gradle.plugin.mpp.GenerateProjectStructureMetadata import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinUsages import org.jetbrains.kotlin.gradle.targets.js.d8.D8RootPlugin import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl @@ -742,8 +743,7 @@ tasks { /* We are using a custom 'kotlin-project-structure-metadata' to ensure 'nativeApiElements' lists 'commonMain' as source set */ - val generateProjectStructureMetadata by existing { - val outputFile = file("build/kotlinProjectStructureMetadata/kotlin-project-structure-metadata.json") + val generateProjectStructureMetadata by existing(GenerateProjectStructureMetadata::class) { val outputTestFile = file("kotlin-project-structure-metadata.beforePatch.json") val patchedFile = file("kotlin-project-structure-metadata.json") @@ -756,16 +756,16 @@ tasks { This will fail if the kotlin-project-structure-metadata.json file would change unnoticed (w/o updating our patched file) */ run { - val outputFileText = outputFile.readText().trim() + val outputFileText = resultFile.readText().trim() val expectedFileContent = outputTestFile.readText().trim() if (outputFileText != expectedFileContent) error( - "${outputFile.path} file content does not match expected content\n\n" + + "${resultFile.path} file content does not match expected content\n\n" + "expected:\n\n$expectedFileContent\n\nactual:\n\n$outputFileText" ) } - patchedFile.copyTo(outputFile, overwrite = true) + patchedFile.copyTo(resultFile, overwrite = true) } }