List of usage examples for org.apache.maven.artifact.resolver DefaultArtifactCollector DefaultArtifactCollector
DefaultArtifactCollector
From source file:org.apache.felix.karaf.tooling.features.GenerateFeaturesXmlMojo.java
License:Apache License
private void readKernelBundles() throws ArtifactResolutionException, ArtifactNotFoundException, MojoExecutionException, ZipException, IOException, DependencyTreeBuilderException { final Collection<Artifact> kernelArtifacts; if (kernelVersion == null) { getLog().info("Step 1: Building list of provided bundle exports"); kernelArtifacts = new HashSet<Artifact>(); DependencyNode tree = dependencyTreeBuilder.buildDependencyTree(project, localRepo, factory, artifactMetadataSource, new ArtifactFilter() { public boolean include(Artifact artifact) { return true; }//w w w . ja va 2s . co m }, new DefaultArtifactCollector()); tree.accept(new DependencyNodeVisitor() { public boolean endVisit(DependencyNode node) { // we want the next sibling too return true; } public boolean visit(DependencyNode node) { if (node.getState() != DependencyNode.OMITTED_FOR_CONFLICT) { Artifact artifact = node.getArtifact(); if (Artifact.SCOPE_PROVIDED.equals(artifact.getScope()) && !artifact.getType().equals("pom")) { kernelArtifacts.add(artifact); } } // we want the children too return true; } }); } else { getLog().info("Step 1 : Building list of kernel exports"); getLog().warn("Use of 'kernelVersion' is deprecated -- use a dependency with scope 'provided' instead"); Artifact kernel = factory.createArtifact("org.apache.felix.karaf", "apache-felix-karaf", kernelVersion, Artifact.SCOPE_PROVIDED, "pom"); resolver.resolve(kernel, remoteRepos, localRepo); kernelArtifacts = getDependencies(kernel); } for (Artifact artifact : kernelArtifacts) { registerKernelBundle(artifact); } getLog().info("...done!"); }
From source file:org.apache.felix.karaf.tooling.features.ValidateFeaturesMojo.java
License:Apache License
private void readProvidedBundles() throws Exception { DependencyNode tree = dependencyTreeBuilder.buildDependencyTree(project, localRepo, factory, artifactMetadataSource, new ArtifactFilter() { public boolean include(Artifact artifact) { return true; }// w ww . j a va 2 s . c o m }, new DefaultArtifactCollector()); tree.accept(new DependencyNodeVisitor() { public boolean endVisit(DependencyNode node) { // we want the next sibling too return true; } public boolean visit(DependencyNode node) { if (node.getState() != DependencyNode.OMITTED_FOR_CONFLICT) { Artifact artifact = node.getArtifact(); info(" scanning %s for exports", artifact); if (Artifact.SCOPE_PROVIDED.equals(artifact.getScope()) && !artifact.getType().equals("pom")) { try { for (ManifestEntry entry : ManifestUtils.getExports(getManifest(artifact))) { getLog().debug(" adding " + entry.getName() + " to list of available packages"); systemExports.add(entry.getName()); } } catch (ArtifactResolutionException e) { error("Unable to find bundle exports for %s: %s", e, artifact, e.getMessage()); } catch (ArtifactNotFoundException e) { error("Unable to find bundle exports for %s: %s", e, artifact, e.getMessage()); } catch (IOException e) { error("Unable to find bundle exports for %s: %s", e, artifact, e.getMessage()); } } } // we want the children too return true; } }); }
From source file:org.nuxeo.build.maven.AntBuildMojo.java
License:Open Source License
@Override public void resolveDependencyTree(Artifact artifact, ArtifactFilter filter, ResolutionListener listener) throws ArtifactResolutionException, ProjectBuildingException { MavenProject mavenProject = projectBuilder.buildFromRepository(artifact, remoteRepositories, localRepository);/*from w w w .j a v a2 s. co m*/ ArtifactCollector collector = new DefaultArtifactCollector(); collector.collect(mavenProject.getDependencyArtifacts(), mavenProject.getArtifact(), mavenProject.getManagedVersionMap(), localRepository, mavenProject.getRemoteArtifactRepositories(), metadataSource, filter, Collections.singletonList(listener)); }
From source file:org.nuxeo.build.maven.EmbeddedMavenClient.java
License:Open Source License
public void resolveDependencyTree(Artifact artifact, ArtifactFilter filter, ResolutionListener listener) throws ArtifactResolutionException, ProjectBuildingException { MavenProject project = mavenProjectBuilder.buildFromRepository(artifact, getRemoteRepositories(), localRepository);// w w w. j a v a 2 s. co m @SuppressWarnings("rawtypes") Set dependencyArtifacts = project.getDependencyArtifacts(); if (dependencyArtifacts == null) { try { dependencyArtifacts = project.createArtifacts(artifactFactory, null, null); } catch (InvalidDependencyVersionException e) { throw new ArtifactResolutionException("Cannot set dependencies", artifact, e); } project.setDependencyArtifacts(dependencyArtifacts); } ArtifactCollector collector = new DefaultArtifactCollector(); collector.collect(dependencyArtifacts, project.getArtifact(), project.getManagedVersionMap(), localRepository, project.getRemoteArtifactRepositories(), artifactMetadataSource, filter, Collections.singletonList(listener)); }