diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/kpm/idea/IdeaKpmMetadataBinaryDependencyResolver.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/kpm/idea/IdeaKpmMetadataBinaryDependencyResolver.kt index 99e56274bc1..ae985a0e2d7 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/kpm/idea/IdeaKpmMetadataBinaryDependencyResolver.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/kpm/idea/IdeaKpmMetadataBinaryDependencyResolver.kt @@ -35,9 +35,9 @@ internal class IdeaKpmMetadataBinaryDependencyResolver( is ArtifactMetadataProvider -> resolution.metadataProvider } - return metadataProvider.read { artifactHandle -> + return metadataProvider.read { artifactContent -> resolution.allVisibleSourceSetNames.mapNotNull { visibleFragmentName -> - val sourceSet = artifactHandle.findSourceSet(visibleFragmentName) ?: return@mapNotNull null + val sourceSet = artifactContent.findSourceSet(visibleFragmentName) ?: return@mapNotNull null val metadataLibrary = sourceSet.metadataLibrary ?: return@mapNotNull null val libraryFile = fragment.project.kotlinTransformedMetadataLibraryDirectoryForIde diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/CompositeMetadataArtifact.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/CompositeMetadataArtifact.kt index 45bbb90cf2c..45d7159e86a 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/CompositeMetadataArtifact.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/CompositeMetadataArtifact.kt @@ -11,7 +11,7 @@ import java.io.File internal interface CompositeMetadataArtifact { interface Library { - val artifactHandle: ArtifactHandle + val artifactContent: ArtifactContent val sourceSet: SourceSet val archiveExtension: String val checksum: Int @@ -54,13 +54,13 @@ internal interface CompositeMetadataArtifact { * Represents a SourceSet packaged into the [CompositeMetadataArtifact] */ interface SourceSet { - val artifactHandle: ArtifactHandle + val artifactContent: ArtifactContent val sourceSetName: String val metadataLibrary: MetadataLibrary? val cinteropMetadataLibraries: List } - interface ArtifactHandle : Closeable { + interface ArtifactContent : Closeable { val moduleDependencyIdentifier: ModuleDependencyIdentifier val moduleDependencyVersion: String val sourceSets: List @@ -71,9 +71,9 @@ internal interface CompositeMetadataArtifact { val moduleDependencyIdentifier: ModuleDependencyIdentifier val moduleDependencyVersion: String - fun open(): ArtifactHandle + fun open(): ArtifactContent - fun read(action: (artifactHandle: ArtifactHandle) -> T): T { + fun read(action: (artifactContent: ArtifactContent) -> T): T { return open().use(action) } } diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/CompositeMetadataArtifactImpl.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/CompositeMetadataArtifactImpl.kt index 513275a96f4..ce5961d7d37 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/CompositeMetadataArtifactImpl.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/CompositeMetadataArtifactImpl.kt @@ -26,11 +26,11 @@ internal class CompositeMetadataArtifactImpl( private val hostSpecificArtifactFilesBySourceSetName: Map ) : CompositeMetadataArtifact { - override fun open(): CompositeMetadataArtifact.ArtifactHandle { + override fun open(): CompositeMetadataArtifact.ArtifactContent { return HandlerImpl() } - inner class HandlerImpl : CompositeMetadataArtifact.ArtifactHandle { + inner class HandlerImpl : CompositeMetadataArtifact.ArtifactContent { override val moduleDependencyIdentifier: ModuleDependencyIdentifier get() = this@CompositeMetadataArtifactImpl.moduleDependencyIdentifier @@ -61,7 +61,7 @@ internal class CompositeMetadataArtifactImpl( } private inner class SourceSetImpl( - override val artifactHandle: CompositeMetadataArtifact.ArtifactHandle, + override val artifactContent: CompositeMetadataArtifact.ArtifactContent, override val sourceSetName: String, private val artifactFile: ArtifactFile ) : CompositeMetadataArtifact.SourceSet, Closeable { @@ -74,7 +74,7 @@ internal class CompositeMetadataArtifactImpl( In this case, return null */ - if (artifactFile.containsDirectory(sourceSetName)) MetadataLibraryImpl(artifactHandle, this, artifactFile) else null + if (artifactFile.containsDirectory(sourceSetName)) MetadataLibraryImpl(artifactContent, this, artifactFile) else null } override val cinteropMetadataLibraries: List by lazy { @@ -89,7 +89,7 @@ internal class CompositeMetadataArtifactImpl( }.toSet() cinteropLibraryNames.map { cinteropLibraryName -> - CInteropMetadataLibraryImpl(artifactHandle, this, cinteropLibraryName, artifactFile) + CInteropMetadataLibraryImpl(artifactContent, this, cinteropLibraryName, artifactFile) } } @@ -99,7 +99,7 @@ internal class CompositeMetadataArtifactImpl( } private inner class MetadataLibraryImpl( - override val artifactHandle: CompositeMetadataArtifact.ArtifactHandle, + override val artifactContent: CompositeMetadataArtifact.ArtifactContent, override val sourceSet: CompositeMetadataArtifact.SourceSet, private val artifactFile: ArtifactFile ) : CompositeMetadataArtifact.MetadataLibrary { @@ -119,9 +119,9 @@ internal class CompositeMetadataArtifactImpl( * org.jetbrains.sample-sampleLibrary-1.0.0-SNAPSHOT-appleAndLinuxMain-Vk5pxQ.klib */ override val relativeFile: File = File(buildString { - append(artifactHandle.moduleDependencyIdentifier) + append(artifactContent.moduleDependencyIdentifier) append("-") - append(artifactHandle.moduleDependencyVersion) + append(artifactContent.moduleDependencyVersion) append("-") append(sourceSet.sourceSetName) append("-") @@ -145,7 +145,7 @@ internal class CompositeMetadataArtifactImpl( } private inner class CInteropMetadataLibraryImpl( - override val artifactHandle: CompositeMetadataArtifact.ArtifactHandle, + override val artifactContent: CompositeMetadataArtifact.ArtifactContent, override val sourceSet: CompositeMetadataArtifact.SourceSet, override val cinteropLibraryName: String, private val artifactFile: ArtifactFile, @@ -166,9 +166,9 @@ internal class CompositeMetadataArtifactImpl( * org.jetbrains.sample_sampleLibrary-cinterop-simple-Vk5pxQ.klib */ override val relativeFile: File = File(buildString { - append(artifactHandle.moduleDependencyIdentifier) + append(artifactContent.moduleDependencyIdentifier) append("-") - append(artifactHandle.moduleDependencyVersion) + append(artifactContent.moduleDependencyVersion) append("-") append(sourceSet.sourceSetName) append("-cinterop") diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/transformMetadataLibraries.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/transformMetadataLibraries.kt index 908ea9cc85d..a0a04c07ffd 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/transformMetadataLibraries.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/transformMetadataLibraries.kt @@ -60,9 +60,9 @@ private fun transformMetadataLibrariesForIde( resolution: MetadataDependencyResolution.ChooseVisibleSourceSets, compositeMetadataArtifact: CompositeMetadataArtifact ): Map> { - return compositeMetadataArtifact.read { artifactHandle -> + return compositeMetadataArtifact.read { artifactContent -> resolution.visibleSourceSetNamesExcludingDependsOn.mapNotNull { visibleSourceSetName -> - val sourceSet = artifactHandle.findSourceSet(visibleSourceSetName) ?: return@mapNotNull null + val sourceSet = artifactContent.findSourceSet(visibleSourceSetName) ?: return@mapNotNull null val sourceSetMetadataLibrary = sourceSet.metadataLibrary ?: return@mapNotNull null val metadataLibraryOutputFile = baseOutputDirectory.resolve(sourceSetMetadataLibrary.relativeFile) metadataLibraryOutputFile.parentFile.mkdirs() @@ -82,9 +82,9 @@ private fun transformMetadataLibrariesForBuild( materializeFiles: Boolean, compositeMetadataArtifact: CompositeMetadataArtifact ): Set { - return compositeMetadataArtifact.read { artifactHandle -> + return compositeMetadataArtifact.read { artifactContent -> resolution.visibleSourceSetNamesExcludingDependsOn.mapNotNull { visibleSourceSetName -> - val sourceSet = artifactHandle.findSourceSet(visibleSourceSetName) ?: return@mapNotNull null + val sourceSet = artifactContent.findSourceSet(visibleSourceSetName) ?: return@mapNotNull null val metadataLibrary = sourceSet.metadataLibrary ?: return@mapNotNull null val metadataLibraryFile = outputDirectory.resolve(metadataLibrary.relativeFile) if (materializeFiles) { diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/native/internal/CInteropMetadataDependencyTransformationTask.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/native/internal/CInteropMetadataDependencyTransformationTask.kt index f5298cc1a8b..3fcd84805c9 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/native/internal/CInteropMetadataDependencyTransformationTask.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/native/internal/CInteropMetadataDependencyTransformationTask.kt @@ -137,9 +137,9 @@ internal open class CInteropMetadataDependencyTransformationTask @Inject constru override fun resolveOutputLibraryFiles(outputDirectory: File, resolutions: Iterable): Set { return resolutions.flatMap { chooseVisibleSourceSets -> if (chooseVisibleSourceSets.metadataProvider !is ArtifactMetadataProvider) return@flatMap emptyList() - chooseVisibleSourceSets.metadataProvider.read { artifactHandle -> + chooseVisibleSourceSets.metadataProvider.read { artifactContent -> chooseVisibleSourceSets.visibleSourceSetsProvidingCInterops - .mapNotNull { visibleSourceSetName -> artifactHandle.findSourceSet(visibleSourceSetName) } + .mapNotNull { visibleSourceSetName -> artifactContent.findSourceSet(visibleSourceSetName) } .flatMap { sourceSet -> sourceSet.cinteropMetadataLibraries } .map { cInteropMetadataLibrary -> outputDirectory.resolve(cInteropMetadataLibrary.relativeFile) } } @@ -211,9 +211,9 @@ internal open class CInteropMetadataDependencyTransformationTask @Inject constru is ProjectMetadataProvider -> Unit /* Extract/Materialize all cinterop files from composite jar file */ - is ArtifactMetadataProvider -> chooseVisibleSourceSets.metadataProvider.read { artifactHandle -> + is ArtifactMetadataProvider -> chooseVisibleSourceSets.metadataProvider.read { artifactContent -> chooseVisibleSourceSets.visibleSourceSetsProvidingCInterops - .mapNotNull { visibleSourceSetName -> artifactHandle.findSourceSet(visibleSourceSetName) } + .mapNotNull { visibleSourceSetName -> artifactContent.findSourceSet(visibleSourceSetName) } .flatMap { sourceSet -> sourceSet.cinteropMetadataLibraries } .forEach { cInteropMetadataLibrary -> cInteropMetadataLibrary.copyIntoDirectory(outputDirectory) } } diff --git a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/CompositeMetadataArtifactTest.kt b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/CompositeMetadataArtifactTest.kt index afe1ff5abec..7055968747d 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/CompositeMetadataArtifactTest.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/CompositeMetadataArtifactTest.kt @@ -42,9 +42,9 @@ class CompositeMetadataArtifactTest { ) - metadataArtifact.read { artifactHandle -> - if (artifactHandle.sourceSets.size != 1) fail("Expected one SourceSet in metadataArtifact") - val sourceSet = artifactHandle.sourceSets.first() + metadataArtifact.read { artifactContent -> + if (artifactContent.sourceSets.size != 1) fail("Expected one SourceSet in metadataArtifact") + val sourceSet = artifactContent.sourceSets.first() assertEquals("testSourceSetName", sourceSet.sourceSetName) assertNull(sourceSet.metadataLibrary, "Expected no 'metadataLibrary' listed for SourceSet") @@ -80,11 +80,11 @@ class CompositeMetadataArtifactTest { hostSpecificArtifactFilesBySourceSetName = emptyMap() ) - metadataArtifact.read { artifactHandle -> - if (artifactHandle.sourceSets.size != 1) - fail("Expected exactly one SourceSet in ${artifactHandle.sourceSets.map { it.sourceSetName }}") + metadataArtifact.read { artifactContent -> + if (artifactContent.sourceSets.size != 1) + fail("Expected exactly one SourceSet in ${artifactContent.sourceSets.map { it.sourceSetName }}") - val sourceSet = artifactHandle.getSourceSet(testSourceSetName) + val sourceSet = artifactContent.getSourceSet(testSourceSetName) val metadataOutputDirectory = temporaryFolder.newFolder() val metadataFile = metadataOutputDirectory.resolve("testSourceSet.klib") @@ -117,9 +117,9 @@ class CompositeMetadataArtifactTest { hostSpecificArtifactFilesBySourceSetName = emptyMap() ) - metadataArtifact.read { artifactHandle -> - val sourceSet = artifactHandle.getSourceSet("testSourceSetName") - assertEquals(listOf(sourceSet), artifactHandle.sourceSets) + metadataArtifact.read { artifactContent -> + val sourceSet = artifactContent.getSourceSet("testSourceSetName") + assertEquals(listOf(sourceSet), artifactContent.sourceSets) assertEquals(emptyList(), sourceSet.cinteropMetadataLibraries, "Expected empty cinteropMetadataLibraries") } @@ -160,11 +160,11 @@ class CompositeMetadataArtifactTest { hostSpecificArtifactFilesBySourceSetName = emptyMap() ) - metadataArtifact.read { artifactHandle -> + metadataArtifact.read { artifactContent -> val metadataOutputDirectory = temporaryFolder.newFolder() /* Extract and assert sourceSetA */ - artifactHandle.getSourceSet("sourceSetA").also { sourceSetA -> + artifactContent.getSourceSet("sourceSetA").also { sourceSetA -> val sourceSetAMetadataFile = metadataOutputDirectory.resolve("sourceSetA.klib") assertNotNull(sourceSetA.metadataLibrary).copyTo(sourceSetAMetadataFile) assertTrue(sourceSetAMetadataFile.isFile, "Expected sourceSetAMetadataFile.isFile") @@ -180,7 +180,7 @@ class CompositeMetadataArtifactTest { } /* Extract and assert sourceSetB */ - artifactHandle.getSourceSet("sourceSetB").also { sourceSetB -> + artifactContent.getSourceSet("sourceSetB").also { sourceSetB -> val sourceSetBMetadataFile = metadataOutputDirectory.resolve("sourceSetB.jar") assertNotNull(sourceSetB.metadataLibrary).copyTo(sourceSetBMetadataFile) assertTrue(sourceSetBMetadataFile.isFile, "Expected sourceSetBMetadataFile.isFile") @@ -235,9 +235,9 @@ class CompositeMetadataArtifactTest { hostSpecificArtifactFilesBySourceSetName = emptyMap() ) - metadataArtifact.read { artifactHandle -> + metadataArtifact.read { artifactContent -> /* Assertions on sourceSetA */ - artifactHandle.getSourceSet("sourceSetA").also { sourceSetA -> + artifactContent.getSourceSet("sourceSetA").also { sourceSetA -> val sourceSetAOutputDirectory = temporaryFolder.newFolder() val sourceSetAInteropMetadataFiles = sourceSetA.cinteropMetadataLibraries.map { cinteropLibrary -> sourceSetAOutputDirectory.resolve("${cinteropLibrary.cinteropLibraryName}.klib").also { file -> @@ -270,7 +270,7 @@ class CompositeMetadataArtifactTest { } /* Assertions on sourceSetB */ - artifactHandle.getSourceSet("sourceSetB").also { sourceSetB -> + artifactContent.getSourceSet("sourceSetB").also { sourceSetB -> val sourceSetBOutputDirectory = temporaryFolder.newFolder() val sourceSetBInteropMetadataFiles = sourceSetB.cinteropMetadataLibraries.map { cinteropLibrary -> sourceSetBOutputDirectory.resolve("${cinteropLibrary.cinteropLibraryName}.klib").also { file ->