void () { List<String> toRemove = new ArrayList<>(); for (JpsExcludeFolder folder : myExcludeFolders) { toRemove.add(folder.getUrl()); Disposer.dispose(folder); } myExcludeFolders.clear(); for (String url : toRemove) { myModule.getExcludeRootsList().removeUrl(url); } }