Use strongly typed task GenerateProjectStructureMetadata to tweak kpsm.json
This commit is contained in:
committed by
Space Team
parent
e0bc0b81c6
commit
5ce2a2cbee
@@ -4,6 +4,7 @@ import com.google.gson.JsonObject
|
|||||||
import org.gradle.api.publish.internal.PublicationInternal
|
import org.gradle.api.publish.internal.PublicationInternal
|
||||||
import org.gradle.jvm.tasks.Jar
|
import org.gradle.jvm.tasks.Jar
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
|
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.plugin.mpp.KotlinUsages
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
|
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
|
||||||
import plugins.configureDefaultPublishing
|
import plugins.configureDefaultPublishing
|
||||||
@@ -281,8 +282,7 @@ tasks {
|
|||||||
dependsOn(jvmTestTasks)
|
dependsOn(jvmTestTasks)
|
||||||
}
|
}
|
||||||
|
|
||||||
val generateProjectStructureMetadata by existing {
|
val generateProjectStructureMetadata by existing(GenerateProjectStructureMetadata::class) {
|
||||||
val outputFile = file("build/kotlinProjectStructureMetadata/kotlin-project-structure-metadata.json")
|
|
||||||
val outputTestFile = file("kotlin-project-structure-metadata.beforePatch.json")
|
val outputTestFile = file("kotlin-project-structure-metadata.beforePatch.json")
|
||||||
val patchedFile = file("kotlin-project-structure-metadata.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)
|
This will fail if the kotlin-project-structure-metadata.json file would change unnoticed (w/o updating our patched file)
|
||||||
*/
|
*/
|
||||||
run {
|
run {
|
||||||
val outputFileText = outputFile.readText().trim()
|
val outputFileText = resultFile.readText().trim()
|
||||||
val expectedFileContent = outputTestFile.readText().trim()
|
val expectedFileContent = outputTestFile.readText().trim()
|
||||||
if (outputFileText != expectedFileContent)
|
if (outputFileText != expectedFileContent)
|
||||||
error(
|
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"
|
"expected:\n\n$expectedFileContent\n\nactual:\n\n$outputFileText"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
patchedFile.copyTo(outputFile, overwrite = true)
|
patchedFile.copyTo(resultFile, overwrite = true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
@file:Suppress("UNUSED_VARIABLE", "NAME_SHADOWING")
|
@file:Suppress("UNUSED_VARIABLE", "NAME_SHADOWING")
|
||||||
import org.gradle.jvm.tasks.Jar
|
import org.gradle.jvm.tasks.Jar
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
|
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.plugin.mpp.KotlinUsages
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.d8.D8RootPlugin
|
import org.jetbrains.kotlin.gradle.targets.js.d8.D8RootPlugin
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
|
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
|
We are using a custom 'kotlin-project-structure-metadata' to ensure 'nativeApiElements' lists 'commonMain' as source set
|
||||||
*/
|
*/
|
||||||
val generateProjectStructureMetadata by existing {
|
val generateProjectStructureMetadata by existing(GenerateProjectStructureMetadata::class) {
|
||||||
val outputFile = file("build/kotlinProjectStructureMetadata/kotlin-project-structure-metadata.json")
|
|
||||||
val outputTestFile = file("kotlin-project-structure-metadata.beforePatch.json")
|
val outputTestFile = file("kotlin-project-structure-metadata.beforePatch.json")
|
||||||
val patchedFile = file("kotlin-project-structure-metadata.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)
|
This will fail if the kotlin-project-structure-metadata.json file would change unnoticed (w/o updating our patched file)
|
||||||
*/
|
*/
|
||||||
run {
|
run {
|
||||||
val outputFileText = outputFile.readText().trim()
|
val outputFileText = resultFile.readText().trim()
|
||||||
val expectedFileContent = outputTestFile.readText().trim()
|
val expectedFileContent = outputTestFile.readText().trim()
|
||||||
if (outputFileText != expectedFileContent)
|
if (outputFileText != expectedFileContent)
|
||||||
error(
|
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"
|
"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