Search in sources :

Example 16 with MavenEmbedderWrapper

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

the class MavenEmbeddersManagerTest method testForSameId.

public void testForSameId() throws Exception {
    MavenEmbedderWrapper one1 = myManager.getEmbedder(MavenEmbeddersManager.FOR_DEPENDENCIES_RESOLVE, null, null);
    MavenEmbedderWrapper one2 = myManager.getEmbedder(MavenEmbeddersManager.FOR_DEPENDENCIES_RESOLVE, null, null);
    assertNotSame(one1, one2);
    myManager.release(one1);
    MavenEmbedderWrapper one3 = myManager.getEmbedder(MavenEmbeddersManager.FOR_DEPENDENCIES_RESOLVE, null, null);
    assertSame(one1, one3);
}
Also used : MavenEmbedderWrapper(org.jetbrains.idea.maven.server.MavenEmbedderWrapper)

Example 17 with MavenEmbedderWrapper

use of org.jetbrains.idea.maven.server.MavenEmbedderWrapper in project intellij-plugins by JetBrains.

the class Flexmojos3GenerateConfigTask method perform.

public void perform(final Project project, final MavenEmbeddersManager embeddersManager, final MavenConsole console, final MavenProgressIndicator indicator) throws MavenProcessCanceledException {
    if (myModule.isDisposed())
        return;
    indicator.setText(FlexBundle.message("generating.flex.config.for", myMavenProject.getDisplayName()));
    final MavenProjectsTree.EmbedderTask task = new MavenProjectsTree.EmbedderTask() {

        public void run(MavenEmbedderWrapper embedder) throws MavenProcessCanceledException {
            List<VirtualFile> temporaryFiles = null;
            final IgnoredFileBean[] filesToIgnoreOriginal = ChangeListManager.getInstance(project).getFilesToIgnore();
            try {
                MavenWorkspaceMap workspaceMap = new MavenWorkspaceMap();
                temporaryFiles = mavenIdToOutputFileMapping(workspaceMap, project, myTree.getProjects());
                embedder.customizeForStrictResolve(workspaceMap, console, indicator);
                final String generateConfigGoal = FlexmojosImporter.FLEXMOJOS_GROUP_ID + ":" + FlexmojosImporter.FLEXMOJOS_ARTIFACT_ID + ":generate-config-" + myMavenProject.getPackaging();
                final MavenExplicitProfiles profilesIds = myMavenProject.getActivatedProfilesIds();
                MavenServerExecutionResult result = embedder.execute(myMavenProject.getFile(), profilesIds.getEnabledProfiles(), profilesIds.getDisabledProfiles(), Collections.singletonList(generateConfigGoal));
                if (result.projectData == null) {
                    myFlexConfigInformer.showFlexConfigWarningIfNeeded(project);
                }
                MavenUtil.invokeAndWaitWriteAction(project, () -> {
                    // need to refresh externally created file
                    final VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByPath(myConfigFilePath);
                    if (file != null) {
                        file.refresh(false, false);
                        updateMainClass(myModule, file);
                    }
                });
            } catch (MavenProcessCanceledException e) {
                throw e;
            } catch (Exception e) {
                myFlexConfigInformer.showFlexConfigWarningIfNeeded(project);
                console.printException(e);
                MavenLog.LOG.warn(e);
            } finally {
                ChangeListManager.getInstance(project).setFilesToIgnore(filesToIgnoreOriginal);
                if (temporaryFiles != null && !temporaryFiles.isEmpty()) {
                    removeTemporaryFiles(project, temporaryFiles);
                }
            }
        }
    };
    myTree.executeWithEmbedder(myMavenProject, embeddersManager, MavenEmbeddersManager.FOR_POST_PROCESSING, console, indicator, task);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) MavenProcessCanceledException(org.jetbrains.idea.maven.utils.MavenProcessCanceledException) MavenExplicitProfiles(org.jetbrains.idea.maven.model.MavenExplicitProfiles) MavenEmbedderWrapper(org.jetbrains.idea.maven.server.MavenEmbedderWrapper) MavenProcessCanceledException(org.jetbrains.idea.maven.utils.MavenProcessCanceledException) IOException(java.io.IOException) ConfigurationException(com.intellij.openapi.options.ConfigurationException) MavenServerExecutionResult(org.jetbrains.idea.maven.server.MavenServerExecutionResult) IgnoredFileBean(com.intellij.openapi.vcs.changes.IgnoredFileBean) MavenWorkspaceMap(org.jetbrains.idea.maven.model.MavenWorkspaceMap)

Aggregations

MavenEmbedderWrapper (org.jetbrains.idea.maven.server.MavenEmbedderWrapper)17 VirtualFile (com.intellij.openapi.vfs.VirtualFile)8 NotNull (org.jetbrains.annotations.NotNull)5 MavenProcessCanceledException (org.jetbrains.idea.maven.utils.MavenProcessCanceledException)5 File (java.io.File)4 THashSet (gnu.trove.THashSet)3 IOException (java.io.IOException)3 Project (com.intellij.openapi.project.Project)2 Key (com.intellij.openapi.util.Key)2 Pair (com.intellij.openapi.util.Pair)2 VfsUtilCore (com.intellij.openapi.vfs.VfsUtilCore)2 MultiMap (com.intellij.util.containers.MultiMap)2 THashMap (gnu.trove.THashMap)2 java.util (java.util)2 Element (org.jdom.Element)2 MavenEmbeddersManager (org.jetbrains.idea.maven.project.MavenEmbeddersManager)2 MavenServerExecutionResult (org.jetbrains.idea.maven.server.MavenServerExecutionResult)2 CommonBundle (com.intellij.CommonBundle)1 Notification (com.intellij.notification.Notification)1 NotificationType (com.intellij.notification.NotificationType)1