Search in sources :

Example 6 with MavenEmbedderWrapper

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

the class MavenProjectsTree method resolvePlugins.

public void resolvePlugins(@NotNull MavenProject mavenProject, @NotNull NativeMavenProjectHolder nativeMavenProject, @NotNull MavenEmbeddersManager embeddersManager, @NotNull MavenConsole console, @NotNull MavenProgressIndicator process) throws MavenProcessCanceledException {
    MavenEmbedderWrapper embedder = embeddersManager.getEmbedder(mavenProject, MavenEmbeddersManager.FOR_PLUGINS_RESOLVE);
    embedder.customizeForResolve(console, process);
    embedder.clearCachesFor(mavenProject.getMavenId());
    Set<File> filesToRefresh = new HashSet<>();
    try {
        process.setText(ProjectBundle.message("maven.downloading.pom.plugins", mavenProject.getDisplayName()));
        for (MavenPlugin each : mavenProject.getDeclaredPlugins()) {
            process.checkCanceled();
            Collection<MavenArtifact> artifacts = embedder.resolvePlugin(each, mavenProject.getRemoteRepositories(), nativeMavenProject, false);
            for (MavenArtifact artifact : artifacts) {
                File pluginJar = artifact.getFile();
                File pluginDir = pluginJar.getParentFile();
                if (pluginDir != null) {
                    // Refresh both *.pom and *.jar files.
                    filesToRefresh.add(pluginDir);
                }
            }
        }
        mavenProject.resetCache();
        firePluginsResolved(mavenProject);
    } finally {
        if (filesToRefresh.size() > 0) {
            LocalFileSystem.getInstance().refreshIoFiles(filesToRefresh);
        }
        embeddersManager.release(embedder);
    }
}
Also used : MavenEmbedderWrapper(org.jetbrains.idea.maven.server.MavenEmbedderWrapper) VirtualFile(com.intellij.openapi.vfs.VirtualFile) THashSet(gnu.trove.THashSet)

Example 7 with MavenEmbedderWrapper

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

the class MavenProjectsTree method resolve.

public void resolve(@NotNull Project project, @NotNull Collection<MavenProject> mavenProjects, @NotNull MavenGeneralSettings generalSettings, @NotNull MavenEmbeddersManager embeddersManager, @NotNull MavenConsole console, @NotNull ResolveContext context, @NotNull MavenProgressIndicator process) throws MavenProcessCanceledException {
    MultiMap<File, MavenProject> projectMultiMap = groupByBasedir(mavenProjects);
    for (Map.Entry<File, Collection<MavenProject>> entry : projectMultiMap.entrySet()) {
        String baseDir = entry.getKey().getPath();
        MavenEmbedderWrapper embedder = embeddersManager.getEmbedder(MavenEmbeddersManager.FOR_DEPENDENCIES_RESOLVE, baseDir, baseDir);
        try {
            embedder.customizeForResolve(getWorkspaceMap(), console, process, generalSettings.isAlwaysUpdateSnapshots());
            doResolve(project, entry.getValue(), generalSettings, embedder, context, process);
        } finally {
            embeddersManager.release(embedder);
        }
    }
}
Also used : MavenEmbedderWrapper(org.jetbrains.idea.maven.server.MavenEmbedderWrapper) VirtualFile(com.intellij.openapi.vfs.VirtualFile) MultiMap(com.intellij.util.containers.MultiMap)

Example 8 with MavenEmbedderWrapper

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

the class MavenProjectsTree method downloadSourcesAndJavadocs.

public MavenArtifactDownloader.DownloadResult downloadSourcesAndJavadocs(@NotNull Project project, @NotNull Collection<MavenProject> projects, @Nullable Collection<MavenArtifact> artifacts, boolean downloadSources, boolean downloadDocs, @NotNull MavenEmbeddersManager embeddersManager, @NotNull MavenConsole console, @NotNull MavenProgressIndicator process) throws MavenProcessCanceledException {
    MultiMap<File, MavenProject> projectMultiMap = groupByBasedir(projects);
    MavenArtifactDownloader.DownloadResult result = new MavenArtifactDownloader.DownloadResult();
    for (Map.Entry<File, Collection<MavenProject>> entry : projectMultiMap.entrySet()) {
        String baseDir = entry.getKey().getPath();
        MavenEmbedderWrapper embedder = embeddersManager.getEmbedder(MavenEmbeddersManager.FOR_DOWNLOAD, baseDir, baseDir);
        try {
            embedder.customizeForResolve(console, process);
            MavenArtifactDownloader.DownloadResult result1 = MavenArtifactDownloader.download(project, this, projects, artifacts, downloadSources, downloadDocs, embedder, process);
            for (MavenProject each : projects) {
                fireArtifactsDownloaded(each);
            }
            result.resolvedDocs.addAll(result1.resolvedDocs);
            result.resolvedSources.addAll(result1.resolvedSources);
            result.unresolvedDocs.addAll(result1.unresolvedDocs);
            result.unresolvedSources.addAll(result1.unresolvedSources);
        } finally {
            embeddersManager.release(embedder);
        }
    }
    return result;
}
Also used : MavenEmbedderWrapper(org.jetbrains.idea.maven.server.MavenEmbedderWrapper) VirtualFile(com.intellij.openapi.vfs.VirtualFile) MultiMap(com.intellij.util.containers.MultiMap)

Example 9 with MavenEmbedderWrapper

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

the class MavenEmbeddersManagerTest method testBasics.

public void testBasics() throws Exception {
    MavenEmbedderWrapper one = myManager.getEmbedder(MavenEmbeddersManager.FOR_FOLDERS_RESOLVE, null, null);
    MavenEmbedderWrapper two = myManager.getEmbedder(MavenEmbeddersManager.FOR_DEPENDENCIES_RESOLVE, null, null);
    assertNotSame(one, two);
}
Also used : MavenEmbedderWrapper(org.jetbrains.idea.maven.server.MavenEmbedderWrapper)

Example 10 with MavenEmbedderWrapper

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

the class MavenEmbeddersManagerTest method testResettingAllCachedAndInUse.

public void testResettingAllCachedAndInUse() throws Exception {
    MavenEmbedderWrapper one1 = myManager.getEmbedder(MavenEmbeddersManager.FOR_DEPENDENCIES_RESOLVE, null, null);
    MavenEmbedderWrapper one2 = myManager.getEmbedder(MavenEmbeddersManager.FOR_FOLDERS_RESOLVE, null, null);
    myManager.release(one1);
    myManager.reset();
    myManager.release(one2);
    MavenEmbedderWrapper one11 = myManager.getEmbedder(MavenEmbeddersManager.FOR_DEPENDENCIES_RESOLVE, null, null);
    MavenEmbedderWrapper one22 = myManager.getEmbedder(MavenEmbeddersManager.FOR_FOLDERS_RESOLVE, null, null);
    assertNotSame(one1, one11);
    assertNotSame(one2, one22);
}
Also used : MavenEmbedderWrapper(org.jetbrains.idea.maven.server.MavenEmbedderWrapper)

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