Use strongly typed task GenerateProjectStructureMetadata to tweak kpsm.json
This commit is contained in:
committed by
Space Team
parent
e0bc0b81c6
commit
5ce2a2cbee
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user