Skip to content

Commit

Permalink
Modify the method on how ComponenetType is determined
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ViktorPetrovski committed Dec 18, 2023
1 parent 908dac6 commit 9ccd4e2
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

0 comments on commit 9ccd4e2

Please sign in to comment.