void (@NotNull String moduleName, @NotNull JpsModuleSourceRootType<?> rootType) { doWriteAction(() -> { Module module = getModule(moduleName); final ModifiableRootModel model = ModuleRootManager.getInstance(module).getModifiableModel(); ContentEntry[] contentEntries = model.getContentEntries(); for (ContentEntry contentEntry : contentEntries) { final SourceFolder[] sourceFolders = contentEntry.getSourceFolders(); for (SourceFolder sourceFolder : sourceFolders) { VirtualFile folderFile = sourceFolder.getFile(); contentEntry.removeSourceFolder(sourceFolder); contentEntry.addSourceFolder(folderFile, rootType); } } model.commit(); }); }