diff --git a/plugins/package-managers/swiftpm/src/main/kotlin/SwiftPm.kt b/plugins/package-managers/swiftpm/src/main/kotlin/SwiftPm.kt index f5a6517d9db0c..564a32dc7c349 100644 --- a/plugins/package-managers/swiftpm/src/main/kotlin/SwiftPm.kt +++ b/plugins/package-managers/swiftpm/src/main/kotlin/SwiftPm.kt @@ -172,16 +172,16 @@ class SwiftPm( } } -private val SwiftPackage.Dependency.id: Identifier +private val SwiftPackage.id: Identifier get() = Identifier( type = PACKAGE_TYPE, namespace = "", - name = getCanonicalName(repositoryUrl), + name = getCanonicalName(url), version = version ) -private fun SwiftPackage.Dependency.toPackage(): Package { - val vcsInfoFromUrl = VcsHost.parseUrl(repositoryUrl) +private fun SwiftPackage.toPackage(): Package { + val vcsInfoFromUrl = VcsHost.parseUrl(url) val vcsInfo = vcsInfoFromUrl.takeUnless { it.revision.isBlank() } ?: vcsInfoFromUrl.copy(revision = version) return createPackage(id, vcsInfo) @@ -241,14 +241,12 @@ internal fun getCanonicalName(repositoryUrl: String): String { }.getOrDefault(normalizedUrl).lowercase() } -private class SwiftPmDependencyHandler : DependencyHandler { - override fun identifierFor(dependency: SwiftPackage.Dependency): Identifier = dependency.id +private class SwiftPmDependencyHandler : DependencyHandler { + override fun identifierFor(dependency: SwiftPackage): Identifier = dependency.id - override fun dependenciesFor(dependency: SwiftPackage.Dependency): Collection = - dependency.dependencies + override fun dependenciesFor(dependency: SwiftPackage): Collection = dependency.dependencies - override fun linkageFor(dependency: SwiftPackage.Dependency): PackageLinkage = PackageLinkage.DYNAMIC + override fun linkageFor(dependency: SwiftPackage): PackageLinkage = PackageLinkage.DYNAMIC - override fun createPackage(dependency: SwiftPackage.Dependency, issues: MutableList): Package = - dependency.toPackage() + override fun createPackage(dependency: SwiftPackage, issues: MutableList): Package = dependency.toPackage() } diff --git a/plugins/package-managers/swiftpm/src/main/kotlin/SwiftPmModel.kt b/plugins/package-managers/swiftpm/src/main/kotlin/SwiftPmModel.kt index a88cafb1911d6..1538aa8f26e03 100644 --- a/plugins/package-managers/swiftpm/src/main/kotlin/SwiftPmModel.kt +++ b/plugins/package-managers/swiftpm/src/main/kotlin/SwiftPmModel.kt @@ -41,16 +41,8 @@ internal data class SwiftPackage( val url: String, val version: String, val path: String, - val dependencies: List -) { - @Serializable - data class Dependency( - val name: String, - val version: String, - @SerialName("url") val repositoryUrl: String, - val dependencies: Set - ) -} + val dependencies: List +) /** * See https://github.com/apple/swift-package-manager/blob/3ef830dddff459e569d6e49c186c3ded33c39bcc/Sources/PackageGraph/PinsStore.swift#L387-L462.