From dd9079f8f25b3ffaf68268994997da671cf28f39 Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Thu, 2 Jan 2025 15:00:03 +0100 Subject: [PATCH] fix(package-managers): Use `projectType` as the ID type for projects Do not use the `managerName` to create IDs for projects, even if in most cases the strings happen to match the respective `projectType`. Signed-off-by: Sebastian Schuberth --- .../package-managers/bazel/src/main/kotlin/Bazel.kt | 2 +- .../package-managers/bower/src/main/kotlin/Bower.kt | 2 +- .../bower/src/main/kotlin/BowerDependencyHandler.kt | 4 ++-- .../bundler/src/main/kotlin/Bundler.kt | 2 +- .../package-managers/cargo/src/main/kotlin/Cargo.kt | 2 +- .../carthage/src/main/kotlin/Carthage.kt | 2 +- .../cocoapods/src/main/kotlin/CocoaPods.kt | 2 +- .../composer/src/main/kotlin/Composer.kt | 2 +- .../package-managers/conan/src/main/kotlin/Conan.kt | 2 +- plugins/package-managers/go/src/main/kotlin/GoMod.kt | 2 +- .../src/main/kotlin/GradleInspector.kt | 2 +- .../gradle/src/main/kotlin/Gradle.kt | 2 +- .../package-managers/maven/src/main/kotlin/Maven.kt | 2 +- .../src/main/kotlin/utils/MavenDependencyHandler.kt | 2 +- .../node/src/main/kotlin/NpmSupport.kt | 4 ++-- .../package-managers/node/src/main/kotlin/npm/Npm.kt | 4 ++-- .../node/src/main/kotlin/npm/NpmDependencyHandler.kt | 2 +- .../node/src/main/kotlin/pnpm/Pnpm.kt | 2 +- .../src/main/kotlin/pnpm/PnpmDependencyHandler.kt | 2 +- .../node/src/main/kotlin/yarn/Yarn.kt | 4 ++-- .../node/src/main/kotlin/yarn2/Yarn2.kt | 2 +- .../package-managers/nuget/src/main/kotlin/NuGet.kt | 2 +- .../main/kotlin/utils/NuGetInspectorExtensions.kt | 4 ++-- plugins/package-managers/pub/src/main/kotlin/Pub.kt | 2 +- .../package-managers/python/src/main/kotlin/Pip.kt | 2 +- .../python/src/main/kotlin/Poetry.kt | 2 +- .../main/kotlin/utils/PythonInspectorExtensions.kt | 8 ++++---- plugins/package-managers/sbt/src/main/kotlin/Sbt.kt | 12 ++++++------ .../spdx/src/main/kotlin/SpdxDocumentFile.kt | 2 +- .../package-managers/stack/src/main/kotlin/Stack.kt | 2 +- .../swiftpm/src/main/kotlin/SwiftPm.kt | 2 +- .../unmanaged/src/main/kotlin/Unmanaged.kt | 6 +++--- 32 files changed, 47 insertions(+), 47 deletions(-) diff --git a/plugins/package-managers/bazel/src/main/kotlin/Bazel.kt b/plugins/package-managers/bazel/src/main/kotlin/Bazel.kt index dadc3c1989a03..d490c0c94c5f8 100644 --- a/plugins/package-managers/bazel/src/main/kotlin/Bazel.kt +++ b/plugins/package-managers/bazel/src/main/kotlin/Bazel.kt @@ -160,7 +160,7 @@ class Bazel( ProjectAnalyzerResult( project = Project( id = Identifier( - type = managerName, + type = projectType, namespace = "", name = moduleMetadata.module?.name ?: VersionControlSystem.getPathInfo(definitionFile).path, version = moduleMetadata.module?.version.orEmpty() diff --git a/plugins/package-managers/bower/src/main/kotlin/Bower.kt b/plugins/package-managers/bower/src/main/kotlin/Bower.kt index ee41d3463868b..1715d94a77948 100644 --- a/plugins/package-managers/bower/src/main/kotlin/Bower.kt +++ b/plugins/package-managers/bower/src/main/kotlin/Bower.kt @@ -87,7 +87,7 @@ class Bower( graphBuilder.addDependencies(projectPackageInfo.toIdentifier(), scopeName, dependencies) } - val project = projectPackageInfo.toProject(definitionFile, SCOPE_NAMES) + val project = projectPackageInfo.toProject(definitionFile, projectType, SCOPE_NAMES) return listOf(ProjectAnalyzerResult(project, emptySet())) } } diff --git a/plugins/package-managers/bower/src/main/kotlin/BowerDependencyHandler.kt b/plugins/package-managers/bower/src/main/kotlin/BowerDependencyHandler.kt index d315655bc9812..651053f81b266 100644 --- a/plugins/package-managers/bower/src/main/kotlin/BowerDependencyHandler.kt +++ b/plugins/package-managers/bower/src/main/kotlin/BowerDependencyHandler.kt @@ -75,10 +75,10 @@ private fun PackageInfo.toPackage() = vcs = toVcsInfo() ) -internal fun PackageInfo.toProject(definitionFile: File, scopeNames: Set) = +internal fun PackageInfo.toProject(definitionFile: File, projectType: String, scopeNames: Set) = with(toPackage()) { Project( - id = id, + id = id.copy(type = projectType), definitionFilePath = VersionControlSystem.getPathInfo(definitionFile).path, authors = authors, declaredLicenses = declaredLicenses, diff --git a/plugins/package-managers/bundler/src/main/kotlin/Bundler.kt b/plugins/package-managers/bundler/src/main/kotlin/Bundler.kt index 2e74964a7ec5f..b90bf7fac3a87 100644 --- a/plugins/package-managers/bundler/src/main/kotlin/Bundler.kt +++ b/plugins/package-managers/bundler/src/main/kotlin/Bundler.kt @@ -210,7 +210,7 @@ class Bundler( val gemsInfo = resolveGemsInfo(workingDir) return with(parseProject(definitionFile, gemsInfo)) { - val projectId = Identifier(managerName, "", name, version) + val projectId = Identifier(projectType, "", name, version) val groupedDeps = getDependencyGroups(workingDir) groupedDeps.forEach { (groupName, dependencyList) -> diff --git a/plugins/package-managers/cargo/src/main/kotlin/Cargo.kt b/plugins/package-managers/cargo/src/main/kotlin/Cargo.kt index 83766e88ce434..ec05aab5c02d7 100644 --- a/plugins/package-managers/cargo/src/main/kotlin/Cargo.kt +++ b/plugins/package-managers/cargo/src/main/kotlin/Cargo.kt @@ -177,7 +177,7 @@ class Cargo( val hashes = readHashes(resolveLockfile(metadata)) val projectPkg = packageById.getValue(projectId).let { cargoPkg -> - cargoPkg.toPackage(hashes).let { it.copy(id = it.id.copy(type = managerName)) } + cargoPkg.toPackage(hashes).let { it.copy(id = it.id.copy(type = projectType)) } } val project = Project( diff --git a/plugins/package-managers/carthage/src/main/kotlin/Carthage.kt b/plugins/package-managers/carthage/src/main/kotlin/Carthage.kt index 4175bdf7903b6..4ef189c1a7b5e 100644 --- a/plugins/package-managers/carthage/src/main/kotlin/Carthage.kt +++ b/plugins/package-managers/carthage/src/main/kotlin/Carthage.kt @@ -74,7 +74,7 @@ class Carthage( ProjectAnalyzerResult( project = Project( id = Identifier( - type = managerName, + type = projectType, namespace = projectInfo.namespace.orEmpty(), name = projectInfo.projectName.orEmpty(), version = projectInfo.revision.orEmpty() diff --git a/plugins/package-managers/cocoapods/src/main/kotlin/CocoaPods.kt b/plugins/package-managers/cocoapods/src/main/kotlin/CocoaPods.kt index 4aaf51401ac78..b069f98c0e063 100644 --- a/plugins/package-managers/cocoapods/src/main/kotlin/CocoaPods.kt +++ b/plugins/package-managers/cocoapods/src/main/kotlin/CocoaPods.kt @@ -136,7 +136,7 @@ class CocoaPods( packages = packages, project = Project( id = Identifier( - type = managerName, + type = projectType, namespace = "", name = getFallbackProjectName(analysisRoot, definitionFile), version = "" diff --git a/plugins/package-managers/composer/src/main/kotlin/Composer.kt b/plugins/package-managers/composer/src/main/kotlin/Composer.kt index 57fcc3b0116e3..c3d0639141fcf 100644 --- a/plugins/package-managers/composer/src/main/kotlin/Composer.kt +++ b/plugins/package-managers/composer/src/main/kotlin/Composer.kt @@ -230,7 +230,7 @@ class Composer( return Project( id = Identifier( - type = managerName, + type = projectType, namespace = namespace, name = name, version = pkgInfo.version.orEmpty() diff --git a/plugins/package-managers/conan/src/main/kotlin/Conan.kt b/plugins/package-managers/conan/src/main/kotlin/Conan.kt index 7d4aeb821943e..1dd899e18c427 100644 --- a/plugins/package-managers/conan/src/main/kotlin/Conan.kt +++ b/plugins/package-managers/conan/src/main/kotlin/Conan.kt @@ -434,7 +434,7 @@ class Conan( return Package( id = Identifier( - type = managerName, + type = projectType, namespace = "", name = inspectPyFile("name") ?: pkgInfo.reference.orEmpty(), version = inspectPyFile("version").orEmpty() diff --git a/plugins/package-managers/go/src/main/kotlin/GoMod.kt b/plugins/package-managers/go/src/main/kotlin/GoMod.kt index 2fb8675d20b5b..cedb5fdab7642 100644 --- a/plugins/package-managers/go/src/main/kotlin/GoMod.kt +++ b/plugins/package-managers/go/src/main/kotlin/GoMod.kt @@ -286,7 +286,7 @@ class GoMod( } Identifier( - type = managerName, + type = projectType, namespace = "", name = getModuleInfos(projectDir).single().path, version = processProjectVcs(projectDir).revision diff --git a/plugins/package-managers/gradle-inspector/src/main/kotlin/GradleInspector.kt b/plugins/package-managers/gradle-inspector/src/main/kotlin/GradleInspector.kt index ccbd8621f4b01..ab1d86d9bf013 100644 --- a/plugins/package-managers/gradle-inspector/src/main/kotlin/GradleInspector.kt +++ b/plugins/package-managers/gradle-inspector/src/main/kotlin/GradleInspector.kt @@ -244,7 +244,7 @@ class GradleInspector( } val projectId = Identifier( - type = "Gradle", + type = projectType, namespace = dependencyTreeModel.group, name = dependencyTreeModel.name, version = dependencyTreeModel.version diff --git a/plugins/package-managers/gradle/src/main/kotlin/Gradle.kt b/plugins/package-managers/gradle/src/main/kotlin/Gradle.kt index d282f53a633e1..2ad779cc6b27c 100644 --- a/plugins/package-managers/gradle/src/main/kotlin/Gradle.kt +++ b/plugins/package-managers/gradle/src/main/kotlin/Gradle.kt @@ -293,7 +293,7 @@ class Gradle( } val projectId = Identifier( - type = managerName, + type = projectType, namespace = dependencyTreeModel.group, name = dependencyTreeModel.name, version = dependencyTreeModel.version diff --git a/plugins/package-managers/maven/src/main/kotlin/Maven.kt b/plugins/package-managers/maven/src/main/kotlin/Maven.kt index 256ae22d5f205..c70db0ec17982 100644 --- a/plugins/package-managers/maven/src/main/kotlin/Maven.kt +++ b/plugins/package-managers/maven/src/main/kotlin/Maven.kt @@ -115,7 +115,7 @@ class Maven( val projectBuildingResult = mvn.buildMavenProject(definitionFile) val mavenProject = projectBuildingResult.project val projectId = Identifier( - type = managerName, + type = projectType, namespace = mavenProject.groupId, name = mavenProject.artifactId, version = mavenProject.version diff --git a/plugins/package-managers/maven/src/main/kotlin/utils/MavenDependencyHandler.kt b/plugins/package-managers/maven/src/main/kotlin/utils/MavenDependencyHandler.kt index bc647c925a7c1..919288fff497f 100644 --- a/plugins/package-managers/maven/src/main/kotlin/utils/MavenDependencyHandler.kt +++ b/plugins/package-managers/maven/src/main/kotlin/utils/MavenDependencyHandler.kt @@ -66,7 +66,7 @@ class MavenDependencyHandler( override fun identifierFor(dependency: DependencyNode): Identifier = Identifier( - type = if (isLocalProject(dependency.identifier())) managerName else "Maven", + type = if (isLocalProject(dependency.identifier())) projectType else "Maven", namespace = dependency.artifact.groupId, name = dependency.artifact.artifactId, version = dependency.artifact.version diff --git a/plugins/package-managers/node/src/main/kotlin/NpmSupport.kt b/plugins/package-managers/node/src/main/kotlin/NpmSupport.kt index 50457daf56b74..54cedd8e172f7 100644 --- a/plugins/package-managers/node/src/main/kotlin/NpmSupport.kt +++ b/plugins/package-managers/node/src/main/kotlin/NpmSupport.kt @@ -230,7 +230,7 @@ internal fun parsePackage( return module } -internal fun parseProject(packageJsonFile: File, analysisRoot: File, managerName: String): Project { +internal fun parseProject(packageJsonFile: File, analysisRoot: File, projectType: String): Project { logger.debug { "Parsing project info from '$packageJsonFile'." } val packageJson = parsePackageJson(packageJsonFile) @@ -258,7 +258,7 @@ internal fun parseProject(packageJsonFile: File, analysisRoot: File, managerName return Project( id = Identifier( - type = managerName, + type = projectType, namespace = namespace, name = projectName, version = version diff --git a/plugins/package-managers/node/src/main/kotlin/npm/Npm.kt b/plugins/package-managers/node/src/main/kotlin/npm/Npm.kt index 0d10a0de3f63e..5d17ed9132b0f 100644 --- a/plugins/package-managers/node/src/main/kotlin/npm/Npm.kt +++ b/plugins/package-managers/node/src/main/kotlin/npm/Npm.kt @@ -102,7 +102,7 @@ class Npm( if (issues.any { it.severity == Severity.ERROR }) { val project = runCatching { - parseProject(definitionFile, analysisRoot, managerName) + parseProject(definitionFile, analysisRoot, projectType) }.getOrElse { logger.error { "Failed to parse project information: ${it.collectMessages()}" } Project.EMPTY @@ -111,7 +111,7 @@ class Npm( return listOf(ProjectAnalyzerResult(project, emptySet(), issues)) } - val project = parseProject(definitionFile, analysisRoot, managerName) + val project = parseProject(definitionFile, analysisRoot, projectType) val projectModuleInfo = listModules(workingDir, issues).undoDeduplication() val scopeNames = Scope.entries diff --git a/plugins/package-managers/node/src/main/kotlin/npm/NpmDependencyHandler.kt b/plugins/package-managers/node/src/main/kotlin/npm/NpmDependencyHandler.kt index 178a14df1b512..e4408dc9205d5 100644 --- a/plugins/package-managers/node/src/main/kotlin/npm/NpmDependencyHandler.kt +++ b/plugins/package-managers/node/src/main/kotlin/npm/NpmDependencyHandler.kt @@ -36,7 +36,7 @@ internal class NpmDependencyHandler(private val npm: Npm) : DependencyHandler() override fun identifierFor(dependency: ModuleInfo): Identifier { - val type = npm.managerName.takeIf { dependency.isProject } ?: "NPM" + val type = if (dependency.isProject) npm.projectType else "NPM" val (namespace, name) = splitNamespaceAndName(dependency.name.orEmpty()) val version = if (dependency.isProject) { readPackageJson(dependency.packageJsonFile).version.orEmpty() diff --git a/plugins/package-managers/node/src/main/kotlin/pnpm/Pnpm.kt b/plugins/package-managers/node/src/main/kotlin/pnpm/Pnpm.kt index 940dec608756c..126da97a94f32 100644 --- a/plugins/package-managers/node/src/main/kotlin/pnpm/Pnpm.kt +++ b/plugins/package-managers/node/src/main/kotlin/pnpm/Pnpm.kt @@ -87,7 +87,7 @@ class Pnpm( val moduleInfosForScope = scopes.associateWith { scope -> listModules(workingDir, scope) } return workspaceModuleDirs.map { projectDir -> - val project = parseProject(projectDir.resolve("package.json"), analysisRoot, managerName) + val project = parseProject(projectDir.resolve("package.json"), analysisRoot, projectType) val scopeNames = scopes.mapTo(mutableSetOf()) { scope -> val scopeName = scope.descriptor diff --git a/plugins/package-managers/node/src/main/kotlin/pnpm/PnpmDependencyHandler.kt b/plugins/package-managers/node/src/main/kotlin/pnpm/PnpmDependencyHandler.kt index edeff23ef7562..7dcadf2e3b58d 100644 --- a/plugins/package-managers/node/src/main/kotlin/pnpm/PnpmDependencyHandler.kt +++ b/plugins/package-managers/node/src/main/kotlin/pnpm/PnpmDependencyHandler.kt @@ -46,7 +46,7 @@ internal class PnpmDependencyHandler(private val pnpm: Pnpm) : DependencyHandler } override fun identifierFor(dependency: Dependency): Identifier { - val type = pnpm.managerName.takeIf { dependency.isProject() } ?: "NPM" + val type = if (dependency.isProject()) pnpm.projectType else "NPM" val namespace = dependency.from.substringBeforeLast("/", "") val name = dependency.from.substringAfterLast("/") val version = if (dependency.isProject()) { diff --git a/plugins/package-managers/node/src/main/kotlin/yarn/Yarn.kt b/plugins/package-managers/node/src/main/kotlin/yarn/Yarn.kt index 61a7f97cc6811..ea48291f03611 100644 --- a/plugins/package-managers/node/src/main/kotlin/yarn/Yarn.kt +++ b/plugins/package-managers/node/src/main/kotlin/yarn/Yarn.kt @@ -180,7 +180,7 @@ open class Yarn( val issues = mutableListOf() val project = runCatching { - parseProject(projectDir.resolve("package.json"), analysisRoot, managerName) + parseProject(projectDir.resolve("package.json"), analysisRoot, projectType) }.getOrElse { issues += createAndLogIssue( source = managerName, @@ -231,7 +231,7 @@ open class Yarn( ): NpmModuleInfo? { val moduleInfo = parsePackageJson(moduleDir, scopes) val dependencies = mutableSetOf() - val packageType = managerName.takeIf { moduleDir.realFile() in projectDirs } ?: "NPM" + val packageType = if (moduleDir.realFile() in projectDirs) projectType else "NPM" val moduleId = splitNamespaceAndName(moduleInfo.name).let { (namespace, name) -> Identifier(packageType, namespace, name, moduleInfo.version) diff --git a/plugins/package-managers/node/src/main/kotlin/yarn2/Yarn2.kt b/plugins/package-managers/node/src/main/kotlin/yarn2/Yarn2.kt index f2b66560d6b6f..0f65fd4a60c87 100644 --- a/plugins/package-managers/node/src/main/kotlin/yarn2/Yarn2.kt +++ b/plugins/package-managers/node/src/main/kotlin/yarn2/Yarn2.kt @@ -410,7 +410,7 @@ class Yarn2( val id = Identifier("Yarn2", namespace, name, version) allProjects += id to Project( - id = id.copy(type = managerName), + id = id.copy(type = projectType), definitionFilePath = VersionControlSystem.getPathInfo(projectFile).path, declaredLicenses = declaredLicenses, vcs = additionalData.vcsFromPackage, diff --git a/plugins/package-managers/nuget/src/main/kotlin/NuGet.kt b/plugins/package-managers/nuget/src/main/kotlin/NuGet.kt index 00a23d805a0f4..712eacc3662a5 100644 --- a/plugins/package-managers/nuget/src/main/kotlin/NuGet.kt +++ b/plugins/package-managers/nuget/src/main/kotlin/NuGet.kt @@ -61,7 +61,7 @@ class NuGet( override fun resolveDependencies(definitionFile: File, labels: Map): List { val result = NuGetInspector.inspect(definitionFile, nugetConfig) - val project = result.toOrtProject(managerName, analysisRoot, definitionFile) + val project = result.toOrtProject(projectType, analysisRoot, definitionFile) val packages = result.dependencies.toOrtPackages() return listOf(ProjectAnalyzerResult(project, packages, collectTopLevelIssues(result))) diff --git a/plugins/package-managers/nuget/src/main/kotlin/utils/NuGetInspectorExtensions.kt b/plugins/package-managers/nuget/src/main/kotlin/utils/NuGetInspectorExtensions.kt index d02ec7df44835..56f60807571d6 100644 --- a/plugins/package-managers/nuget/src/main/kotlin/utils/NuGetInspectorExtensions.kt +++ b/plugins/package-managers/nuget/src/main/kotlin/utils/NuGetInspectorExtensions.kt @@ -51,12 +51,12 @@ private fun List.toAuthors(): Set = } internal fun NuGetInspector.Result.toOrtProject( - managerName: String, + projectType: String, analysisRoot: File, definitionFile: File ): Project { val id = Identifier( - type = managerName, + type = projectType, namespace = "", name = definitionFile.relativeTo(analysisRoot).invariantSeparatorsPath, version = "" diff --git a/plugins/package-managers/pub/src/main/kotlin/Pub.kt b/plugins/package-managers/pub/src/main/kotlin/Pub.kt index 5675be0e36b7a..80371fb5d9865 100644 --- a/plugins/package-managers/pub/src/main/kotlin/Pub.kt +++ b/plugins/package-managers/pub/src/main/kotlin/Pub.kt @@ -507,7 +507,7 @@ class Pub( return Project( id = Identifier( - type = managerName, + type = projectType, namespace = "", name = pubspec.name, version = pubspec.version.orEmpty() diff --git a/plugins/package-managers/python/src/main/kotlin/Pip.kt b/plugins/package-managers/python/src/main/kotlin/Pip.kt index c80cf302de861..2d6335398542d 100644 --- a/plugins/package-managers/python/src/main/kotlin/Pip.kt +++ b/plugins/package-managers/python/src/main/kotlin/Pip.kt @@ -101,7 +101,7 @@ class Pip( override fun resolveDependencies(definitionFile: File, labels: Map): List { val result = runPythonInspector(definitionFile) { detectPythonVersion(definitionFile.parentFile) } - val project = result.toOrtProject(managerName, analysisRoot, definitionFile) + val project = result.toOrtProject(projectType, analysisRoot, definitionFile) val packages = result.packages.toOrtPackages() return listOf(ProjectAnalyzerResult(project, packages)) diff --git a/plugins/package-managers/python/src/main/kotlin/Poetry.kt b/plugins/package-managers/python/src/main/kotlin/Poetry.kt index a44f17daab194..6e1bc49601158 100644 --- a/plugins/package-managers/python/src/main/kotlin/Poetry.kt +++ b/plugins/package-managers/python/src/main/kotlin/Poetry.kt @@ -88,7 +88,7 @@ class Poetry( val project = Project.EMPTY.copy( id = Identifier( - type = managerName, + type = projectType, namespace = "", name = definitionFile.relativeTo(analysisRoot).path, version = VersionControlSystem.getCloneInfo(definitionFile.parentFile).revision diff --git a/plugins/package-managers/python/src/main/kotlin/utils/PythonInspectorExtensions.kt b/plugins/package-managers/python/src/main/kotlin/utils/PythonInspectorExtensions.kt index 01f3401ed87e7..22f89cfbbc740 100644 --- a/plugins/package-managers/python/src/main/kotlin/utils/PythonInspectorExtensions.kt +++ b/plugins/package-managers/python/src/main/kotlin/utils/PythonInspectorExtensions.kt @@ -36,11 +36,11 @@ import org.ossreviewtoolkit.model.VcsType private const val TYPE = "PyPI" internal fun PythonInspector.Result.toOrtProject( - managerName: String, + projectType: String, analysisRoot: File, definitionFile: File ): Project { - val id = resolveIdentifier(managerName, analysisRoot, definitionFile) + val id = resolveIdentifier(projectType, analysisRoot, definitionFile) val setupProject = projects.find { it.path.endsWith("/setup.py") } val projectData = setupProject?.packageData?.singleOrNull() @@ -61,7 +61,7 @@ internal fun PythonInspector.Result.toOrtProject( } private fun PythonInspector.Result.resolveIdentifier( - managerName: String, + projectType: String, analysisRoot: File, definitionFile: File ): Identifier { @@ -103,7 +103,7 @@ private fun PythonInspector.Result.resolveIdentifier( val projectVersion = setupVersion.ifEmpty { requirementsVersion } return Identifier( - type = managerName, + type = projectType, namespace = "", name = projectName, version = projectVersion diff --git a/plugins/package-managers/sbt/src/main/kotlin/Sbt.kt b/plugins/package-managers/sbt/src/main/kotlin/Sbt.kt index 03a966991e916..d7b299d91f155 100644 --- a/plugins/package-managers/sbt/src/main/kotlin/Sbt.kt +++ b/plugins/package-managers/sbt/src/main/kotlin/Sbt.kt @@ -102,26 +102,26 @@ class Sbt( // definition file paths. val workingDir = getCommonParentFile(definitionFiles) - logger.info { "Determined '$workingDir' as the $managerName project root directory." } + logger.info { "Determined '$workingDir' as the $projectType project root directory." } val sbtVersion = options[OPTION_SBT_VERSION] val sbtVersions = getBuildSbtVersions(workingDir) when { - sbtVersion != null -> logger.info { "Using configured custom $managerName version $sbtVersion." } + sbtVersion != null -> logger.info { "Using configured custom $projectType version $sbtVersion." } sbtVersions.isEmpty() -> - logger.info { "The build does not configure any $managerName version to be used." } + logger.info { "The build does not configure any $projectType version to be used." } sbtVersions.size == 1 -> - logger.info { "The build configures $managerName version ${sbtVersions.first()} to be used." } + logger.info { "The build configures $projectType version ${sbtVersions.first()} to be used." } else -> - logger.warn { "The build configures multiple different $managerName versions to be used: $sbtVersions" } + logger.warn { "The build configures multiple different $projectType versions to be used: $sbtVersions" } } val lowestSbtVersion = sbtVersion?.let { Semver(it) } ?: sbtVersions.firstOrNull() ?: getGlobalSbtVersion() require(lowestSbtVersion?.isLowerThan(Semver(LOWEST_SUPPORTED_SBT_VERSION)) != true) { - "Build $managerName version $lowestSbtVersion is lower than version $LOWEST_SUPPORTED_SBT_VERSION." + "Build $projectType version $lowestSbtVersion is lower than version $LOWEST_SUPPORTED_SBT_VERSION." } // TODO: Consider auto-detecting the Java version based on the SBT version. See: diff --git a/plugins/package-managers/spdx/src/main/kotlin/SpdxDocumentFile.kt b/plugins/package-managers/spdx/src/main/kotlin/SpdxDocumentFile.kt index 0a31f352629c9..ab749b5c99f40 100644 --- a/plugins/package-managers/spdx/src/main/kotlin/SpdxDocumentFile.kt +++ b/plugins/package-managers/spdx/src/main/kotlin/SpdxDocumentFile.kt @@ -277,7 +277,7 @@ class SpdxDocumentFile( */ private fun SpdxPackage.toIdentifier() = Identifier( - type = managerName, + type = projectType, namespace = listOfNotNull(supplier, originator).firstOrNull() ?.withoutPrefix(SpdxConstants.ORGANIZATION).orEmpty().sanitize(), name = name.sanitize(), diff --git a/plugins/package-managers/stack/src/main/kotlin/Stack.kt b/plugins/package-managers/stack/src/main/kotlin/Stack.kt index 6c099fe47fdbe..5ca14c1cca60f 100644 --- a/plugins/package-managers/stack/src/main/kotlin/Stack.kt +++ b/plugins/package-managers/stack/src/main/kotlin/Stack.kt @@ -145,7 +145,7 @@ class Stack( else -> throw IOException("Multiple *.cabal files found in '$cabalFiles'.") } - val projectPackage = parseCabalFile(cabalFile.readText(), managerName) + val projectPackage = parseCabalFile(cabalFile.readText(), projectType) return Project( id = projectPackage.id, diff --git a/plugins/package-managers/swiftpm/src/main/kotlin/SwiftPm.kt b/plugins/package-managers/swiftpm/src/main/kotlin/SwiftPm.kt index 2324635f328d6..f916493d8701c 100644 --- a/plugins/package-managers/swiftpm/src/main/kotlin/SwiftPm.kt +++ b/plugins/package-managers/swiftpm/src/main/kotlin/SwiftPm.kt @@ -175,7 +175,7 @@ class SwiftPm( val vcsInfo = VersionControlSystem.forDirectory(definitionFile.parentFile)?.getInfo().orEmpty() val projectIdentifier = Identifier( - type = managerName, + type = projectType, version = vcsInfo.revision, namespace = "", name = getFallbackProjectName(analysisRoot, definitionFile) diff --git a/plugins/package-managers/unmanaged/src/main/kotlin/Unmanaged.kt b/plugins/package-managers/unmanaged/src/main/kotlin/Unmanaged.kt index 5ec28d77194e4..c43b17da53a54 100644 --- a/plugins/package-managers/unmanaged/src/main/kotlin/Unmanaged.kt +++ b/plugins/package-managers/unmanaged/src/main/kotlin/Unmanaged.kt @@ -76,7 +76,7 @@ class Unmanaged( } Identifier( - type = managerName, + type = projectType, namespace = "", name = definitionFile.name, version = "" @@ -89,7 +89,7 @@ class Unmanaged( val manifestPath = vcsInfo.url.parseRepoManifestPath() Identifier( - type = managerName, + type = projectType, namespace = manifestPath?.substringBeforeLast('/').orEmpty(), name = manifestPath?.substringAfterLast('/')?.removeSuffix(".xml") ?: vcsInfo.url.split('/').last().removeSuffix(".git"), @@ -100,7 +100,7 @@ class Unmanaged( else -> { // For all non-GitRepo VCSes derive the name from the VCS URL. Identifier( - type = managerName, + type = projectType, namespace = "", name = vcsInfo.url.split('/').last().removeSuffix(".git"), version = vcsInfo.revision