public static Set<JpsModule> getModulesIncludedInArtifacts(final @NotNull Collection<? extends JpsArtifact> artifacts) {
    final Set<JpsModule> modules = new HashSet<>();
    for (JpsArtifact artifact : artifacts) {
      processPackagingElements(artifact.getRootElement(), element -> {
        if (element instanceof JpsModuleOutputPackagingElement) {
          ContainerUtil.addIfNotNull(modules, ((JpsModuleOutputPackagingElement)element).getModuleReference().resolve());
        }
        return true;
      });
    }
    return modules;
  }
public static Set<JpsModule> getModulesIncludedInArtifacts(final @NotNull Collection<? extends JpsArtifact> artifacts)