diff --git a/libraries/stdlib/build.gradle.kts b/libraries/stdlib/build.gradle.kts index d3a4284a3f8..b9dc2985f96 100644 --- a/libraries/stdlib/build.gradle.kts +++ b/libraries/stdlib/build.gradle.kts @@ -743,6 +743,37 @@ tasks { if (project.hasProperty("kotlin.stdlib.test.long.running")) { check.configure { dependsOn(jvmLongRunningTest) } } + + /* + 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 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) + } + } + } diff --git a/libraries/stdlib/kotlin-project-structure-metadata.beforePatch.json b/libraries/stdlib/kotlin-project-structure-metadata.beforePatch.json new file mode 100644 index 00000000000..9efe00b95c1 --- /dev/null +++ b/libraries/stdlib/kotlin-project-structure-metadata.beforePatch.json @@ -0,0 +1,52 @@ +{ + "projectStructure": { + "formatVersion": "0.3.3", + "isPublishedAsRoot": "true", + "variants": [ + { + "name": "jsApiElements", + "sourceSet": [ + "commonMain" + ] + }, + { + "name": "jsRuntimeElements", + "sourceSet": [ + "commonMain" + ] + }, + { + "name": "jsV1ApiElements", + "sourceSet": [ + "commonMain" + ] + }, + { + "name": "jsV1RuntimeElements", + "sourceSet": [ + "commonMain" + ] + }, + { + "name": "jvmApiElements", + "sourceSet": [ + "commonMain" + ] + }, + { + "name": "jvmRuntimeElements", + "sourceSet": [ + "commonMain" + ] + } + ], + "sourceSets": [ + { + "name": "commonMain", + "dependsOn": [], + "moduleDependency": [], + "binaryLayout": "klib" + } + ] + } +} \ No newline at end of file diff --git a/libraries/stdlib/kotlin-project-structure-metadata.json b/libraries/stdlib/kotlin-project-structure-metadata.json new file mode 100644 index 00000000000..446a7367558 --- /dev/null +++ b/libraries/stdlib/kotlin-project-structure-metadata.json @@ -0,0 +1,58 @@ +{ + "projectStructure": { + "formatVersion": "0.3.3", + "isPublishedAsRoot": "true", + "variants": [ + { + "name": "jsApiElements", + "sourceSet": [ + "commonMain" + ] + }, + { + "name": "jsRuntimeElements", + "sourceSet": [ + "commonMain" + ] + }, + { + "name": "jsV1ApiElements", + "sourceSet": [ + "commonMain" + ] + }, + { + "name": "jsV1RuntimeElements", + "sourceSet": [ + "commonMain" + ] + }, + { + "name": "jvmApiElements", + "sourceSet": [ + "commonMain" + ] + }, + { + "name": "jvmRuntimeElements", + "sourceSet": [ + "commonMain" + ] + }, + { + "name": "nativeApiElements", + "sourceSet": [ + "commonMain" + ] + } + ], + "sourceSets": [ + { + "name": "commonMain", + "dependsOn": [], + "moduleDependency": [], + "binaryLayout": "klib" + } + ] + } +} \ No newline at end of file