From 22738085d51846e732fde6881352acddc5a0ca9a Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Sat, 18 Jan 2025 10:04:58 +0100 Subject: [PATCH] feat(analyzer): Also fail early if managers for the same type are enabled This fails early additionally to the check the `DependencyGraphNavigator` does in `directDependencies()`. The latter check is still and anyway required to unambiguously get the direct dependencies for a project unless the API is changed. Signed-off-by: Sebastian Schuberth --- analyzer/src/main/kotlin/Analyzer.kt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/analyzer/src/main/kotlin/Analyzer.kt b/analyzer/src/main/kotlin/Analyzer.kt index 4e28abe2e5d64..e6b565c35572c 100644 --- a/analyzer/src/main/kotlin/Analyzer.kt +++ b/analyzer/src/main/kotlin/Analyzer.kt @@ -103,6 +103,15 @@ class Analyzer(private val config: AnalyzerConfiguration, private val labels: Ma Pair(manager, mappedFiles).takeIf { mappedFiles.isNotEmpty() } }.toMap(mutableMapOf()) + // Fail early if multiple managers for the same project type are enabled. + managedFiles.keys.groupBy { it.projectType }.forEach { (projectType, managers) -> + val managerNames = managers.map { it.managerName } + requireNotNull(managers.singleOrNull()) { + "All of the $managerNames managers are able to manage '$projectType' projects. Please enable only " + + "one of them." + } + } + // Check whether there are unmanaged files (because of deactivated, unsupported, or non-present package // managers) which need to get attached to an artificial "unmanaged" project. val managedDirs = managedFiles.values.flatten().mapNotNull { it.parentFile }