Set<Module> (final @NotNull Collection<? extends Artifact> artifacts, final @NotNull Project project) { final Set<Module> modules = new HashSet<>(); final PackagingElementResolvingContext resolvingContext = ArtifactManager.getInstance(project).getResolvingContext(); for (Artifact artifact : artifacts) { processPackagingElements(artifact, null, element -> { if (element instanceof ModuleOutputPackagingElement) { ContainerUtil.addIfNotNull(modules, ((ModuleOutputPackagingElement)element).findModule(resolvingContext)); } return true; }, resolvingContext, true); } return modules; }