void (@NotNull Project project, final @NotNull VirtualFile baseDir, final @NotNull Ref<Module> moduleRef, boolean isProjectCreatedWithWizard) { VirtualFile projectsRoot = LocalFileSystem.getInstance().findFileByPath(ProjectUtil.getProjectPath()); if (projectsRoot == null || !VfsUtilCore.isAncestor(projectsRoot, baseDir, true)) return; ApplicationManager.getApplication().runWriteAction(() -> { for (Module module : ModuleManager.getInstance(project).getModules()) { ModuleRootManager rootManager = ModuleRootManager.getInstance(module); ModifiableRootModel rootModel = rootManager.getModifiableModel(); for (ContentEntry entry : rootModel.getContentEntries()) { VirtualFile entryFile = entry.getFile(); if (entryFile != null && VfsUtilCore.isAncestor(projectsRoot, entryFile, true)) { rootModel.removeContentEntry(entry); } } rootModel.inheritSdk(); rootModel.commit(); } }); }