List of usage examples for org.apache.maven.plugin.descriptor PluginDescriptor getPluginArtifact
public Artifact getPluginArtifact()
From source file:org.jetbrains.idea.maven.server.embedder.Maven2ServerEmbedderImpl.java
License:Apache License
@Override public Collection<MavenArtifact> resolvePlugin(@Nonnull final MavenPlugin plugin, @Nonnull final List<MavenRemoteRepository> repositories, final int nativeMavenProjectId, final boolean transitive) throws MavenServerProcessCanceledException, RemoteException { return doExecute(new Executor<Collection<MavenArtifact>>() { @Override/*from w ww. j a v a2 s . c o m*/ public Collection<MavenArtifact> execute() throws Exception { try { Plugin mavenPlugin = new Plugin(); mavenPlugin.setGroupId(plugin.getGroupId()); mavenPlugin.setArtifactId(plugin.getArtifactId()); mavenPlugin.setVersion(plugin.getVersion()); MavenProject project = RemoteNativeMavenProjectHolder.findProjectById(nativeMavenProjectId); PluginDescriptor result = getComponent(PluginManager.class).verifyPlugin(mavenPlugin, project, myImpl.getSettings(), myImpl.getLocalRepository()); Map<MavenArtifactInfo, MavenArtifact> resolvedArtifacts = new HashMap<MavenArtifactInfo, MavenArtifact>(); Artifact pluginArtifact = result.getPluginArtifact(); MavenArtifactInfo artifactInfo = new MavenArtifactInfo(pluginArtifact.getGroupId(), pluginArtifact.getArtifactId(), pluginArtifact.getVersion(), pluginArtifact.getType(), null); resolveIfNecessary(artifactInfo, repositories, resolvedArtifacts); if (transitive) { // todo try to use parallel downloading for (Artifact each : (Iterable<Artifact>) result.getIntroducedDependencyArtifacts()) { resolveIfNecessary( new MavenArtifactInfo(each.getGroupId(), each.getArtifactId(), each.getVersion(), each.getType(), null), repositories, resolvedArtifacts); } for (ComponentDependency each : (List<ComponentDependency>) result.getDependencies()) { resolveIfNecessary( new MavenArtifactInfo(each.getGroupId(), each.getArtifactId(), each.getVersion(), each.getType(), null), repositories, resolvedArtifacts); } } return new HashSet<MavenArtifact>(resolvedArtifacts.values()); } catch (Exception e) { Maven2ServerGlobals.getLogger().info(e); return Collections.emptyList(); } } }); }