diff --git a/analyzer/build.gradle.kts b/analyzer/build.gradle.kts index fb3bfb90d02e6..ae62b885963b0 100644 --- a/analyzer/build.gradle.kts +++ b/analyzer/build.gradle.kts @@ -49,6 +49,7 @@ dependencies { api(project(":model")) implementation(project(":downloader")) + implementation(project(":spdx-utils")) implementation(project(":utils")) implementation("com.fasterxml.jackson.module:jackson-module-kotlin:$jacksonVersion") diff --git a/analyzer/src/main/kotlin/Analyzer.kt b/analyzer/src/main/kotlin/Analyzer.kt index 7cdc8d9de8314..61f20ea16644f 100644 --- a/analyzer/src/main/kotlin/Analyzer.kt +++ b/analyzer/src/main/kotlin/Analyzer.kt @@ -71,7 +71,7 @@ class Analyzer(private val config: AnalyzerConfiguration) { log.debug { "Using the following configuration settings:\n$repositoryConfiguration" } - // Map files by the package manager factory that manages them. + // Associate files by the package manager factory that manages them. val factoryFiles = if (packageManagers.size == 1 && absoluteProjectPath.isFile) { // If only one package manager is activated, treat the given path as definition file for that package // manager despite its name. @@ -80,6 +80,7 @@ class Analyzer(private val config: AnalyzerConfiguration) { PackageManager.findManagedFiles(absoluteProjectPath, packageManagers).toMutableMap() } + // Associate mapped files by the package manager that manages them. val managedFiles = factoryFiles.mapNotNull { (factory, files) -> val manager = factory.create(absoluteProjectPath, config, repositoryConfiguration) val mappedFiles = manager.mapDefinitionFiles(files) diff --git a/analyzer/src/main/kotlin/PackageManager.kt b/analyzer/src/main/kotlin/PackageManager.kt index 6a8fd89a67e20..bdfe22fec8521 100644 --- a/analyzer/src/main/kotlin/PackageManager.kt +++ b/analyzer/src/main/kotlin/PackageManager.kt @@ -42,6 +42,7 @@ import org.ossreviewtoolkit.model.VcsType import org.ossreviewtoolkit.model.config.AnalyzerConfiguration import org.ossreviewtoolkit.model.config.RepositoryConfiguration import org.ossreviewtoolkit.model.createAndLogIssue +import org.ossreviewtoolkit.spdx.VCS_DIRECTORIES import org.ossreviewtoolkit.utils.collectMessagesAsString import org.ossreviewtoolkit.utils.isSymbolicLink import org.ossreviewtoolkit.utils.log @@ -70,13 +71,7 @@ abstract class PackageManager( */ val ALL by lazy { LOADER.iterator().asSequence().toList() } - private val IGNORED_DIRECTORY_MATCHERS = listOf( - // Ignore VCS configuration directories. - ".git", - ".hg", - ".repo", - ".svn", - "CVS", + private val PACKAGE_MANAGER_DIRECTORIES = listOf( // Ignore intermediate build system directories. ".gradle", "node_modules", @@ -86,7 +81,9 @@ abstract class PackageManager( // Ignore virtual environments in Python. "lib/python2.*/dist-packages", "lib/python3.*/site-packages" - ).map { + ) + + private val IGNORED_DIRECTORY_MATCHERS = (VCS_DIRECTORIES + PACKAGE_MANAGER_DIRECTORIES).map { FileSystems.getDefault().getPathMatcher("glob:**/$it") } diff --git a/analyzer/src/main/kotlin/managers/Unmanaged.kt b/analyzer/src/main/kotlin/managers/Unmanaged.kt index f2c7bd7d27ee0..1784416425cd7 100644 --- a/analyzer/src/main/kotlin/managers/Unmanaged.kt +++ b/analyzer/src/main/kotlin/managers/Unmanaged.kt @@ -34,7 +34,9 @@ import org.ossreviewtoolkit.model.config.RepositoryConfiguration import org.ossreviewtoolkit.utils.log /** - * A fake [PackageManager] for projects that do not use any of the known package managers. + * A fake [PackageManager] for projects that do not use any of the known package managers, or no package manager at all. + * It is required as in ORT's data model e.g. scan results need to be attached to projects (or packages), so files that + * do not belong to any other project need to be attached to somewhere. */ class Unmanaged( name: String, diff --git a/spdx-utils/src/main/kotlin/SpdxUtils.kt b/spdx-utils/src/main/kotlin/SpdxUtils.kt index 378d471d6857e..cc70dd11eec1d 100644 --- a/spdx-utils/src/main/kotlin/SpdxUtils.kt +++ b/spdx-utils/src/main/kotlin/SpdxUtils.kt @@ -42,7 +42,7 @@ val NON_LICENSE_FILENAMES = listOf( /** * A list of directories used by version control systems to store metadata. */ -internal val VCS_DIRECTORIES = listOf( +val VCS_DIRECTORIES = listOf( ".git", ".hg", ".repo",