void (RuntimeModuleDescriptor descriptor, Set<RuntimeModuleDescriptor> rootModules, Set<RuntimeModuleDescriptor> visited, List<IncludedRuntimeModule> result) { for (RuntimeModuleDescriptor dependency : descriptor.getDependencies()) { if (!visited.add(dependency)) continue; if (!rootModules.contains(dependency)) { result.add(new IncludedRuntimeModuleImpl(dependency, ModuleImportance.SERVICE, Collections.emptySet())); } collectDependencies(dependency, rootModules, visited, result); } }