void (final Project project, final boolean updateTargetFoldersOnly) { final MavenProjectsManager manager = MavenProjectsManager.getInstance(project); final MavenImportingSettings settings = manager.getImportingSettings(); WriteAction.run(() -> { List<ModifiableRootModel> rootModels = new ArrayList<>(); for (Module each : ModuleManager.getInstance(project).getModules()) { MavenProject mavenProject = manager.findProject(each); if (mavenProject == null) continue; MavenRootModelAdapter a = new MavenRootModelAdapter( new MavenRootModelAdapterLegacyImpl(mavenProject, each, ProjectDataManager.getInstance().createModifiableModelsProvider(project))); new MavenLegacyFoldersImporter(mavenProject, settings, a).config(updateTargetFoldersOnly); ModifiableRootModel model = a.getRootModel(); if (model.isChanged()) { rootModels.add(model); } else { model.dispose(); } } if (!rootModels.isEmpty()) { ModifiableModelCommitter.multiCommit(rootModels, ModuleManager.getInstance(rootModels.get((0)).getProject()).getModifiableModel()); } }); }