Skip to content

Commit

Permalink
analyzer: Add a generic SPDX-document-based "fake" package manager
Browse files Browse the repository at this point in the history
See spdx/spdx-spec#439 for details.

Signed-off-by: Sebastian Schuberth <sebastian.schuberth@bosch.io>
  • Loading branch information
sschuberth committed Jul 6, 2020
1 parent 29418cc commit 177c358
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
Empty file.
57 changes: 57 additions & 0 deletions analyzer/src/main/kotlin/managers/SpdxDocumentFile.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright (C) 2020 Bosch.IO GmbH
*
* 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
*
* http://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.analyzer.managers

import java.io.File

import org.ossreviewtoolkit.analyzer.AbstractPackageManagerFactory
import org.ossreviewtoolkit.analyzer.PackageManager
import org.ossreviewtoolkit.model.ProjectAnalyzerResult
import org.ossreviewtoolkit.model.config.AnalyzerConfiguration
import org.ossreviewtoolkit.model.config.RepositoryConfiguration

/**
* A "fake" package manager implementation that uses SPDX documents as "marker" files to declare projects and describe
* packages. See https://github.com/spdx/spdx-spec/issues/439 for details.
*/
class SpdxDocumentFile(
managerName: String,
analysisRoot: File,
analyzerConfig: AnalyzerConfiguration,
repoConfig: RepositoryConfiguration
) : PackageManager(managerName, analysisRoot, analyzerConfig, repoConfig) {
class Factory : AbstractPackageManagerFactory<SpdxDocumentFile>("SpdxDocumentFile") {
override val globsForDefinitionFiles = listOf("*.spdx.yml", "*.spdx.yaml", "*.spdx.json")

override fun create(
analysisRoot: File,
analyzerConfig: AnalyzerConfiguration,
repoConfig: RepositoryConfiguration
) = SpdxDocumentFile(managerName, analysisRoot, analyzerConfig, repoConfig)
}

override fun resolveDependencies(definitionFile: File): List<ProjectAnalyzerResult> {
val results = mutableListOf<ProjectAnalyzerResult>()

val workingDir = definitionFile.parentFile

return results
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ org.ossreviewtoolkit.analyzer.managers.Pip$Factory
org.ossreviewtoolkit.analyzer.managers.Pipenv$Factory
org.ossreviewtoolkit.analyzer.managers.Pub$Factory
org.ossreviewtoolkit.analyzer.managers.Sbt$Factory
org.ossreviewtoolkit.analyzer.managers.SpdxDocumentFile$Factory
org.ossreviewtoolkit.analyzer.managers.Stack$Factory
org.ossreviewtoolkit.analyzer.managers.Yarn$Factory

0 comments on commit 177c358

Please sign in to comment.