MPP: Merge module dependencies if one of them has COMPILE scope

This commit is contained in:
Alexey Sedunov
2018-10-03 18:43:39 +03:00
parent d36ee02499
commit da06e49b19
@@ -16,6 +16,12 @@ fun addModuleDependencyIfNeeded(
) {
val dependencyScope = if (testScope) DependencyScope.TEST else DependencyScope.COMPILE
val existingEntry = rootModel.findModuleOrderEntry(dependeeModule)
if (existingEntry != null && existingEntry.scope == dependencyScope) return
if (existingEntry != null) {
val existingScope = existingEntry.scope
if (existingScope == DependencyScope.COMPILE || existingScope == dependencyScope) return
if (dependencyScope == DependencyScope.COMPILE) {
rootModel.removeOrderEntry(existingEntry)
}
}
rootModel.addModuleOrderEntry(dependeeModule).also { it.scope = dependencyScope }
}