diff --git a/plugins/package-managers/swiftpm/src/main/kotlin/SwiftPm.kt b/plugins/package-managers/swiftpm/src/main/kotlin/SwiftPm.kt index ff38f08467c4b..f5a6517d9db0c 100644 --- a/plugins/package-managers/swiftpm/src/main/kotlin/SwiftPm.kt +++ b/plugins/package-managers/swiftpm/src/main/kotlin/SwiftPm.kt @@ -30,6 +30,7 @@ import org.ossreviewtoolkit.model.DependencyGraph import org.ossreviewtoolkit.model.Identifier import org.ossreviewtoolkit.model.Issue import org.ossreviewtoolkit.model.Package +import org.ossreviewtoolkit.model.PackageLinkage import org.ossreviewtoolkit.model.Project import org.ossreviewtoolkit.model.ProjectAnalyzerResult import org.ossreviewtoolkit.model.RemoteArtifact @@ -38,6 +39,7 @@ import org.ossreviewtoolkit.model.config.AnalyzerConfiguration import org.ossreviewtoolkit.model.config.RepositoryConfiguration import org.ossreviewtoolkit.model.orEmpty import org.ossreviewtoolkit.model.utils.DependencyGraphBuilder +import org.ossreviewtoolkit.model.utils.DependencyHandler import org.ossreviewtoolkit.utils.common.CommandLineTool import org.ossreviewtoolkit.utils.common.Os import org.ossreviewtoolkit.utils.common.toUri @@ -170,7 +172,7 @@ class SwiftPm( } } -internal val SwiftPackage.Dependency.id: Identifier +private val SwiftPackage.Dependency.id: Identifier get() = Identifier( type = PACKAGE_TYPE, namespace = "", @@ -178,7 +180,7 @@ internal val SwiftPackage.Dependency.id: Identifier version = version ) -internal fun SwiftPackage.Dependency.toPackage(): Package { +private fun SwiftPackage.Dependency.toPackage(): Package { val vcsInfoFromUrl = VcsHost.parseUrl(repositoryUrl) val vcsInfo = vcsInfoFromUrl.takeUnless { it.revision.isBlank() } ?: vcsInfoFromUrl.copy(revision = version) @@ -238,3 +240,15 @@ internal fun getCanonicalName(repositoryUrl: String): String { it.host + it.path.removeSuffix(".git") }.getOrDefault(normalizedUrl).lowercase() } + +private class SwiftPmDependencyHandler : DependencyHandler { + override fun identifierFor(dependency: SwiftPackage.Dependency): Identifier = dependency.id + + override fun dependenciesFor(dependency: SwiftPackage.Dependency): Collection = + dependency.dependencies + + override fun linkageFor(dependency: SwiftPackage.Dependency): PackageLinkage = PackageLinkage.DYNAMIC + + override fun createPackage(dependency: SwiftPackage.Dependency, issues: MutableList): Package = + dependency.toPackage() +} diff --git a/plugins/package-managers/swiftpm/src/main/kotlin/SwiftPmDependencyHandler.kt b/plugins/package-managers/swiftpm/src/main/kotlin/SwiftPmDependencyHandler.kt deleted file mode 100644 index 4468e1b18b153..0000000000000 --- a/plugins/package-managers/swiftpm/src/main/kotlin/SwiftPmDependencyHandler.kt +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2022 The ORT Project Authors (see ) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * License-Filename: LICENSE - */ - -package org.ossreviewtoolkit.plugins.packagemanagers.swiftpm - -import org.ossreviewtoolkit.model.Identifier -import org.ossreviewtoolkit.model.Issue -import org.ossreviewtoolkit.model.Package -import org.ossreviewtoolkit.model.PackageLinkage -import org.ossreviewtoolkit.model.PackageLinkage.DYNAMIC -import org.ossreviewtoolkit.model.utils.DependencyHandler -import org.ossreviewtoolkit.plugins.packagemanagers.swiftpm.SwiftPackage.Dependency - -/** - * A specialized [DependencyHandler] implementation for SPM. - */ -class SwiftPmDependencyHandler : DependencyHandler { - override fun identifierFor(dependency: Dependency): Identifier = dependency.id - - override fun dependenciesFor(dependency: Dependency): Collection = dependency.dependencies - - override fun linkageFor(dependency: Dependency): PackageLinkage = DYNAMIC - - override fun createPackage(dependency: Dependency, issues: MutableList): Package = dependency.toPackage() -}