From 26716c1d930cdba7ff7530de435b9e18c5b768d4 Mon Sep 17 00:00:00 2001 From: viktorp Date: Fri, 15 Dec 2023 11:48:27 +0100 Subject: [PATCH] Modify the method on how ComponenetType is determined The old code worked for Gradle modules, but with the RulerCli and the possibility to pass componenets that are build with other build systems this is no longer correct --- .../ruler/common/dependency/DependencySanitizer.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ruler-common/src/main/java/com/spotify/ruler/common/dependency/DependencySanitizer.kt b/ruler-common/src/main/java/com/spotify/ruler/common/dependency/DependencySanitizer.kt index 2bb11abc..14021f7a 100644 --- a/ruler-common/src/main/java/com/spotify/ruler/common/dependency/DependencySanitizer.kt +++ b/ruler-common/src/main/java/com/spotify/ruler/common/dependency/DependencySanitizer.kt @@ -58,9 +58,14 @@ class DependencySanitizer(private val classNameSanitizer: ClassNameSanitizer) { } } - /** Determines the correct component type for a given [entry]. */ + private val versionRegex = Regex("^\\d+\\.\\d+\\.\\d.*") + + /** + * Determines the correct component type for a given [entry]. + * Assuming that all external dependencies do have a version number in the format XX.XX.XX + * */ private fun getComponentType(entry: DependencyEntry): ComponentType = when { - entry.component.startsWith(':') -> ComponentType.INTERNAL - else -> ComponentType.EXTERNAL + versionRegex.containsMatchIn(entry.component.substringAfterLast(":","")) -> ComponentType.EXTERNAL + else -> ComponentType.INTERNAL } }