[Gradle][MPP] Rename CompositeMetadataArtifact.ArtifactHandle to ArtifactContent
^KT-48135 Verification Pending
This commit is contained in:
committed by
Space
parent
75cc378cac
commit
59d0bd5e39
+2
-2
@@ -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
|
||||
|
||||
+5
-5
@@ -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<CInteropMetadataLibrary>
|
||||
}
|
||||
|
||||
interface ArtifactHandle : Closeable {
|
||||
interface ArtifactContent : Closeable {
|
||||
val moduleDependencyIdentifier: ModuleDependencyIdentifier
|
||||
val moduleDependencyVersion: String
|
||||
val sourceSets: List<SourceSet>
|
||||
@@ -71,9 +71,9 @@ internal interface CompositeMetadataArtifact {
|
||||
val moduleDependencyIdentifier: ModuleDependencyIdentifier
|
||||
val moduleDependencyVersion: String
|
||||
|
||||
fun open(): ArtifactHandle
|
||||
fun open(): ArtifactContent
|
||||
|
||||
fun <T> read(action: (artifactHandle: ArtifactHandle) -> T): T {
|
||||
fun <T> read(action: (artifactContent: ArtifactContent) -> T): T {
|
||||
return open().use(action)
|
||||
}
|
||||
}
|
||||
|
||||
+11
-11
@@ -26,11 +26,11 @@ internal class CompositeMetadataArtifactImpl(
|
||||
private val hostSpecificArtifactFilesBySourceSetName: Map<String, File>
|
||||
) : 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<CompositeMetadataArtifact.CInteropMetadataLibrary> 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")
|
||||
|
||||
+4
-4
@@ -60,9 +60,9 @@ private fun transformMetadataLibrariesForIde(
|
||||
resolution: MetadataDependencyResolution.ChooseVisibleSourceSets,
|
||||
compositeMetadataArtifact: CompositeMetadataArtifact
|
||||
): Map<String /* visibleSourceSetName */, Iterable<File>> {
|
||||
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<File> {
|
||||
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) {
|
||||
|
||||
+4
-4
@@ -137,9 +137,9 @@ internal open class CInteropMetadataDependencyTransformationTask @Inject constru
|
||||
override fun resolveOutputLibraryFiles(outputDirectory: File, resolutions: Iterable<ChooseVisibleSourceSets>): Set<File> {
|
||||
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) }
|
||||
}
|
||||
|
||||
+16
-16
@@ -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 ->
|
||||
|
||||
Reference in New Issue
Block a user