Skip to content

Commit 49cb302

Browse files
committed
chores(analyzer): Do not throw exception if duplicate packages
When duplicate packages or projects are found in the dependency tree, print a warning instead of throwing an exception and inteerrupting the scan. Duplicate packages may arise when the same package is imported twice, in these cases the dependency tree will be completed as the package is imported at least once. Signed-off-by: Stefano Bennati <[email protected]>
1 parent 546550e commit 49cb302

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

analyzer/src/main/kotlin/AnalyzerResultBuilder.kt

+6-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
* License-Filename: LICENSE
1818
*/
1919

20+
import org.apache.logging.log4j.kotlin.logger
21+
2022
package org.ossreviewtoolkit.analyzer
2123

2224
import org.ossreviewtoolkit.model.AnalyzerResult
@@ -41,9 +43,10 @@ class AnalyzerResultBuilder {
4143

4244
fun build(excludes: Excludes = Excludes.EMPTY): AnalyzerResult {
4345
val duplicates = (projects.map { it.toPackage() } + packages).getDuplicates { it.id }
44-
require(duplicates.isEmpty()) {
45-
"Unable to create the AnalyzerResult as it contains packages and projects with the same ids: " +
46-
duplicates.values
46+
if (duplicates.isNotEmpty()) {
47+
logger.warn {
48+
"AnalyzerResult contains packages and projects with the same ids: ${duplicates.values}"
49+
}
4750
}
4851

4952
return AnalyzerResult(projects, packages, issues, dependencyGraphs)

0 commit comments

Comments
 (0)