Search in sources :

Example 1 with MavenImportingSettings

use of org.jetbrains.idea.maven.project.MavenImportingSettings in project intellij-community by JetBrains.

the class MavenFoldersImporter method updateProjectFolders.

public static void updateProjectFolders(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(mavenProject, each, new IdeModifiableModelsProviderImpl(project));
            new MavenFoldersImporter(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());
        }
    });
}
Also used : ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) MavenProjectsManager(org.jetbrains.idea.maven.project.MavenProjectsManager) MavenProject(org.jetbrains.idea.maven.project.MavenProject) IdeModifiableModelsProviderImpl(com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl) ArrayList(java.util.ArrayList) MavenImportingSettings(org.jetbrains.idea.maven.project.MavenImportingSettings) Module(com.intellij.openapi.module.Module)

Aggregations

IdeModifiableModelsProviderImpl (com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl)1 Module (com.intellij.openapi.module.Module)1 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)1 ArrayList (java.util.ArrayList)1 MavenImportingSettings (org.jetbrains.idea.maven.project.MavenImportingSettings)1 MavenProject (org.jetbrains.idea.maven.project.MavenProject)1 MavenProjectsManager (org.jetbrains.idea.maven.project.MavenProjectsManager)1