Example usage for org.apache.maven.plugin.descriptor PluginDescriptor getIntroducedDependencyArtifacts

List of usage examples for org.apache.maven.plugin.descriptor PluginDescriptor getIntroducedDependencyArtifacts

Introduction

In this page you can find the example usage for org.apache.maven.plugin.descriptor PluginDescriptor getIntroducedDependencyArtifacts.

Prototype

public Set<Artifact> getIntroducedDependencyArtifacts() 

Source Link

Usage

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//  w w w  .j  av a  2 s .com
        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();
            }
        }
    });
}