@RequiresEdt
  public static void addSourceRoots(@NotNull Module module, @NotNull Collection<VirtualFile> roots) {
    if (roots.isEmpty()) {
      return;
    }

    ApplicationManager.getApplication().runWriteAction(
      () -> {
        final ModifiableRootModel model = ModuleRootManager.getInstance(module).getModifiableModel();
        for (VirtualFile root : roots) {
          boolean added = false;
          for (ContentEntry entry : model.getContentEntries()) {
            final VirtualFile file = entry.getFile();
            if (file != null && VfsUtilCore.isAncestor(file, root, true)) {
              entry.addSourceFolder(root, false);
              added = true;
            }
          }

          if (!added) {
            model.addContentEntry(root).addSourceFolder(root, false);
          }
        }
        model.commit();
      }
    );
  }
@RequiresEdt
  public static void addSourceRoots(@NotNull Module module, @NotNull Collection<VirtualFile> roots)