-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
analyzer: Add a generic SPDX-document-based "fake" package manager
See spdx/spdx-spec#439 for details. Signed-off-by: Sebastian Schuberth <sebastian.schuberth@bosch.io>
- Loading branch information
1 parent
29418cc
commit 177c358
Showing
3 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters