[Gradle] Fix possible CME in sourceSetsMetadataOutputs

Iterating over source sets and waiting for compilation wasn't safe.
 Because compilation upon configuration were able
 to add more source sets.

 Awaiting source sets first should solve the issue.

^KT-61652 Verification Pending
This commit is contained in:
Anton Lakotka
2023-09-19 12:34:05 +02:00
committed by Space Team
parent 7d047261d9
commit 1a35d01fe1
@@ -64,9 +64,7 @@ internal suspend fun Project.collectSourceSetMetadataOutputs(): Map<SourceSetNam
}
private suspend fun KotlinMultiplatformExtension.sourceSetsMetadataOutputs(): Map<KotlinSourceSet, FileCollection?> {
KotlinPluginLifecycle.Stage.AfterFinaliseDsl.await()
return sourceSets.associateWith { sourceSet ->
return awaitSourceSets().associateWith { sourceSet ->
when (val compilation = project.findMetadataCompilation(sourceSet)) {
null -> null
is KotlinCommonCompilation -> compilation.output.classesDirs