void (final String path) { ApplicationManager.getApplication().runWriteAction(() -> { ModuleRootManager rm = ModuleRootManager.getInstance(myModule); ModifiableRootModel m = rm.getModifiableModel(); for (ContentEntry e : m.getContentEntries()) { if (!Comparing.equal(e.getFile(), myRoot)) continue; e.addExcludeFolder(VfsUtilCore.pathToUrl(path)); } m.commit(); }); }