From 446cd1eec9289659d466e022ff532fd2b4bbdea6 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Fri, 24 Nov 2023 04:51:53 +0100 Subject: [PATCH] [kotlin-test] kpsm.json patching KT-61969 Adds source set relationships for additional variants and also slightly stretches common source sets included into jvm variant --- libraries/kotlin.test/build.gradle.kts | 27 ++++ ...roject-structure-metadata.beforePatch.json | 96 ++++++++++++ .../kotlin-project-structure-metadata.json | 148 ++++++++++++++++++ 3 files changed, 271 insertions(+) create mode 100644 libraries/kotlin.test/kotlin-project-structure-metadata.beforePatch.json create mode 100644 libraries/kotlin.test/kotlin-project-structure-metadata.json diff --git a/libraries/kotlin.test/build.gradle.kts b/libraries/kotlin.test/build.gradle.kts index 75172dd110b..bd1dee7cd4e 100644 --- a/libraries/kotlin.test/build.gradle.kts +++ b/libraries/kotlin.test/build.gradle.kts @@ -269,6 +269,33 @@ tasks { val allTests by existing { dependsOn(jvmTestTasks) } + + val generateProjectStructureMetadata by existing { + val outputFile = file("build/kotlinProjectStructureMetadata/kotlin-project-structure-metadata.json") + val outputTestFile = file("kotlin-project-structure-metadata.beforePatch.json") + val patchedFile = file("kotlin-project-structure-metadata.json") + + inputs.file(patchedFile) + inputs.file(outputTestFile) + + doLast { + /* + Check that the generated 'outputFile' by default matches our expectations stored in the .beforePatch file + 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 expectedFileContent = outputTestFile.readText().trim() + if (outputFileText != expectedFileContent) + error( + "${outputFile.path} file content does not match expected content\n\n" + + "expected:\n\n$expectedFileContent\n\nactual:\n\n$outputFileText" + ) + } + + patchedFile.copyTo(outputFile, overwrite = true) + } + } } configurations { diff --git a/libraries/kotlin.test/kotlin-project-structure-metadata.beforePatch.json b/libraries/kotlin.test/kotlin-project-structure-metadata.beforePatch.json new file mode 100644 index 00000000000..a9ea58e3172 --- /dev/null +++ b/libraries/kotlin.test/kotlin-project-structure-metadata.beforePatch.json @@ -0,0 +1,96 @@ +{ + "projectStructure": { + "formatVersion": "0.3.3", + "isPublishedAsRoot": "true", + "variants": [ + { + "name": "jsApiElements", + "sourceSet": [ + "assertionsCommonMain", + "commonMain", + "annotationsCommonMain" + ] + }, + { + "name": "jsRuntimeElements", + "sourceSet": [ + "assertionsCommonMain", + "commonMain", + "annotationsCommonMain" + ] + }, + { + "name": "jvmApiElements", + "sourceSet": [ + "assertionsCommonMain", + "commonMain" + ] + }, + { + "name": "jvmRuntimeElements", + "sourceSet": [ + "assertionsCommonMain", + "commonMain" + ] + }, + { + "name": "wasmJsApiElements", + "sourceSet": [ + "assertionsCommonMain", + "commonMain", + "annotationsCommonMain" + ] + }, + { + "name": "wasmJsRuntimeElements", + "sourceSet": [ + "assertionsCommonMain", + "commonMain", + "annotationsCommonMain" + ] + }, + { + "name": "wasmWasiApiElements", + "sourceSet": [ + "assertionsCommonMain", + "commonMain", + "annotationsCommonMain" + ] + }, + { + "name": "wasmWasiRuntimeElements", + "sourceSet": [ + "assertionsCommonMain", + "commonMain", + "annotationsCommonMain" + ] + } + ], + "sourceSets": [ + { + "name": "annotationsCommonMain", + "dependsOn": [ + "commonMain" + ], + "moduleDependency": [], + "binaryLayout": "klib" + }, + { + "name": "assertionsCommonMain", + "dependsOn": [ + "commonMain" + ], + "moduleDependency": [], + "binaryLayout": "klib" + }, + { + "name": "commonMain", + "dependsOn": [], + "moduleDependency": [ + "org.jetbrains.kotlin:kotlin-stdlib" + ], + "binaryLayout": "klib" + } + ] + } +} \ No newline at end of file diff --git a/libraries/kotlin.test/kotlin-project-structure-metadata.json b/libraries/kotlin.test/kotlin-project-structure-metadata.json new file mode 100644 index 00000000000..9376d49e125 --- /dev/null +++ b/libraries/kotlin.test/kotlin-project-structure-metadata.json @@ -0,0 +1,148 @@ +{ + "projectStructure": { + "formatVersion": "0.3.3", + "isPublishedAsRoot": "true", + "variants": [ + { + "name": "jsApiElements", + "sourceSet": [ + "assertionsCommonMain", + "commonMain", + "annotationsCommonMain" + ] + }, + { + "name": "jsRuntimeElements", + "sourceSet": [ + "assertionsCommonMain", + "commonMain", + "annotationsCommonMain" + ] + }, + { + "name": "jvmApiElements", + "sourceSet": [ + "assertionsCommonMain", + "commonMain", + "annotationsCommonMain" + ] + }, + { + "name": "jvmRuntimeElements", + "sourceSet": [ + "assertionsCommonMain", + "commonMain", + "annotationsCommonMain" + ] + }, + { + "name": "jvmJUnitApiElements", + "sourceSet": [ + "annotationsCommonMain", + "commonMain" + ] + }, + { + "name": "jvmJUnitRuntimeElements", + "sourceSet": [ + "annotationsCommonMain", + "commonMain" + ] + }, + { + "name": "jvmJUnit5ApiElements", + "sourceSet": [ + "annotationsCommonMain", + "commonMain" + ] + }, + { + "name": "jvmJUnit5RuntimeElements", + "sourceSet": [ + "annotationsCommonMain", + "commonMain" + ] + }, + { + "name": "jvmTestNGApiElements", + "sourceSet": [ + "annotationsCommonMain", + "commonMain" + ] + }, + { + "name": "jvmTestNGRuntimeElements", + "sourceSet": [ + "annotationsCommonMain", + "commonMain" + ] + }, + { + "name": "nativeApiElements", + "sourceSet": [ + "assertionsCommonMain", + "commonMain", + "annotationsCommonMain" + ] + }, + { + "name": "wasmJsApiElements", + "sourceSet": [ + "assertionsCommonMain", + "commonMain", + "annotationsCommonMain" + ] + }, + { + "name": "wasmJsRuntimeElements", + "sourceSet": [ + "assertionsCommonMain", + "commonMain", + "annotationsCommonMain" + ] + }, + { + "name": "wasmWasiApiElements", + "sourceSet": [ + "assertionsCommonMain", + "commonMain", + "annotationsCommonMain" + ] + }, + { + "name": "wasmWasiRuntimeElements", + "sourceSet": [ + "assertionsCommonMain", + "commonMain", + "annotationsCommonMain" + ] + } + ], + "sourceSets": [ + { + "name": "annotationsCommonMain", + "dependsOn": [ + "commonMain" + ], + "moduleDependency": [], + "binaryLayout": "klib" + }, + { + "name": "assertionsCommonMain", + "dependsOn": [ + "commonMain" + ], + "moduleDependency": [], + "binaryLayout": "klib" + }, + { + "name": "commonMain", + "dependsOn": [], + "moduleDependency": [ + "org.jetbrains.kotlin:kotlin-stdlib" + ], + "binaryLayout": "klib" + } + ] + } +} \ No newline at end of file