Skip to content

Commit 46924a6

Browse files
committed
chores(analyzer): Print warning 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 46924a6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

analyzer/src/main/kotlin/AnalyzerResultBuilder.kt

Lines changed: 4 additions & 3 deletions
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,8 @@ 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 {"Unable to create the AnalyzerResult as it contains packages and projects with the same ids: ${duplicates.values}"}
4748
}
4849

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

0 commit comments

Comments
 (0)