Skip to content

Commit

Permalink
Improve transitive module resolution on --origin and --destination flags
Browse files Browse the repository at this point in the history
  • Loading branch information
ryru committed Sep 10, 2024
1 parent 5b71298 commit 75b383f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import ch.addere.dga.core.domain.model.Configuration
import ch.addere.dga.core.domain.model.Dependency
import ch.addere.dga.core.domain.model.FilteredConfiguration
import ch.addere.dga.core.domain.model.FilteredModules
import ch.addere.dga.core.domain.model.Module
import ch.addere.dga.core.domain.service.ConfigurationService
import ch.addere.dga.core.domain.service.DependencyService
import ch.addere.dga.core.domain.service.ModuleService
Expand Down Expand Up @@ -60,20 +61,15 @@ class FilterService(
)

if (filterConfig.includeTransitiveDependencies) {
// val transitiveDependencies: Set<Dependency> = filteredDependencies
// .flatMap { setOf(it.origin, it.destination) }
// .toSet()
// .flatMap {
// dependencyRelationService.allDependenciesOf(
// it,
// requestedCanonicalConfigurations
// )
// }
// .toSet()
val transitiveDependencies: Set<Dependency> = requestedCanonicalModules.flatMap {
val relevantModules: Set<Module> =
filteredDependencies.flatMap { setOf(it.origin, it.destination) }.toSet()
val relevantConfigs: Set<Configuration> =
filteredDependencies.map { it.configuration }.toSet()

val transitiveDependencies: Set<Dependency> = relevantModules.flatMap {
dependencySearchService.findAllDependenciesUsedByModule(
it,
requestedCanonicalConfigurations
relevantConfigs
)
}.toSet()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ class DependencySearchServiceImpl(private val dependencyRepository: DependencyRe
origin: Module,
withConfigurations: Collection<Configuration>
): Set<Dependency> {
println("call with origin = $origin")
val allDependenciesWithSameOrigin: Set<Dependency> =
dependencyRepository.getAllDependencies()
.filter { dependency ->
Expand All @@ -57,7 +56,6 @@ class DependencySearchServiceImpl(private val dependencyRepository: DependencyRe
)
}
.toSet()
println(allDependenciesWithSameOrigin.joinToString(", "))

return if (allDependenciesWithSameOrigin.isEmpty()) {
emptySet()
Expand Down

0 comments on commit 75b383f

Please sign in to comment.