Collection<Artifact> (@NotNull final Module module) { ArtifactManager artifactManager = ArtifactManager.getInstance(module.getProject()); final PackagingElementResolvingContext context = artifactManager.getResolvingContext(); final Set<Artifact> result = new HashSet<>(); Processor<PackagingElement<?>> processor = element -> { if (element instanceof ProductionModuleOutputPackagingElement && module.equals(((ProductionModuleOutputPackagingElement)element).findModule(context))) { return false; } if (element instanceof ArtifactPackagingElement && result.contains(((ArtifactPackagingElement)element).findArtifact(context))) { return false; } return true; }; for (Artifact artifact : artifactManager.getSortedArtifacts()) { boolean contains = !processPackagingElements(artifact, null, processor, context, true); if (contains) { result.add(artifact); } } return result; }