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);
}
}
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);
}
}
}
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;
}
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);
}
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);
}
Aggregations