List of usage examples for org.apache.maven.project MavenProject getDependencyArtifacts
@Deprecated
public Set<Artifact> getDependencyArtifacts()
From source file:org.apache.cxf.maven_plugin.wadlto.OptionLoader.java
License:Apache License
public static List<WadlOption> loadWsdlOptionsFromDependencies(MavenProject project, Option defaultOptions, File outputDir) {/* ww w. jav a 2s. c o m*/ List<WadlOption> options = new ArrayList<>(); Set<Artifact> dependencies = project.getDependencyArtifacts(); for (Artifact artifact : dependencies) { WadlOption option = generateWsdlOptionFromArtifact(artifact, outputDir); if (option != null) { if (defaultOptions != null) { option.merge(defaultOptions); } options.add(option); } } return options; }
From source file:org.apache.cxf.maven_plugin.wsdl2java.WsdlOptionLoader.java
License:Apache License
public static List<GenericWsdlOption> loadWsdlOptionsFromDependencies(MavenProject project, File outputDir) { List<GenericWsdlOption> options = new ArrayList<>(); Set<Artifact> dependencies = CastUtils.cast(project.getDependencyArtifacts()); for (Artifact artifact : dependencies) { WsdlOption option = generateWsdlOptionFromArtifact(artifact, outputDir); if (option != null) { options.add(option);/* w w w . j a v a 2s . c o m*/ } } return options; }
From source file:org.apache.cxf.maven_plugin.wsdl2js.WSDL2JavaScriptMojo.java
License:Apache License
public static List<GenericWsdlOption> loadWsdlOptionsFromDependencies(MavenProject project, Option defaultOptions, File outputDir) { List<GenericWsdlOption> options = new ArrayList<>(); Set<Artifact> dependencies = CastUtils.cast(project.getDependencyArtifacts()); for (Artifact artifact : dependencies) { WsdlOption option = new WsdlOption(); if (WsdlUtilities.fillWsdlOptionFromArtifact(option, artifact, outputDir)) { if (defaultOptions != null) { option.merge(defaultOptions); }/*from ww w.j a v a 2s . c om*/ options.add(option); } } return options; }
From source file:org.apache.felix.bundleplugin.BundleAllPlugin.java
License:Apache License
/** * Bundle a project and its transitive dependencies up to some depth level * /*from w w w .ja v a 2s . c om*/ * @param project * @param maxDepth how deep to process the dependency tree * @throws MojoExecutionException */ protected BundleInfo bundleAll(MavenProject project, int maxDepth) throws MojoExecutionException { if (alreadyBundled(project.getArtifact())) { getLog().debug("Ignoring project already processed " + project.getArtifact()); return null; } if (m_artifactsBeingProcessed.contains(project.getArtifact())) { getLog().warn("Ignoring artifact due to dependency cycle " + project.getArtifact()); return null; } m_artifactsBeingProcessed.add(project.getArtifact()); DependencyNode dependencyTree; try { dependencyTree = m_dependencyTreeBuilder.buildDependencyTree(project, localRepository, m_factory, m_artifactMetadataSource, null, m_collector); } catch (DependencyTreeBuilderException e) { throw new MojoExecutionException("Unable to build dependency tree", e); } BundleInfo bundleInfo = new BundleInfo(); if (!dependencyTree.hasChildren()) { /* no need to traverse the tree */ return bundleRoot(project, bundleInfo); } getLog().debug("Will bundle the following dependency tree" + LS + dependencyTree); for (Iterator it = dependencyTree.inverseIterator(); it.hasNext();) { DependencyNode node = (DependencyNode) it.next(); if (!it.hasNext()) { /* this is the root, current project */ break; } if (node.getState() != DependencyNode.INCLUDED) { continue; } if (Artifact.SCOPE_SYSTEM.equals(node.getArtifact().getScope())) { getLog().debug("Ignoring system scoped artifact " + node.getArtifact()); continue; } Artifact artifact; try { artifact = resolveArtifact(node.getArtifact()); } catch (ArtifactNotFoundException e) { if (ignoreMissingArtifacts) { continue; } throw new MojoExecutionException("Artifact was not found in the repo" + node.getArtifact(), e); } node.getArtifact().setFile(artifact.getFile()); int nodeDepth = node.getDepth(); if (nodeDepth > maxDepth) { /* node is deeper than we want */ getLog().debug( "Ignoring " + node.getArtifact() + ", depth is " + nodeDepth + ", bigger than " + maxDepth); continue; } MavenProject childProject; try { childProject = m_mavenProjectBuilder.buildFromRepository(artifact, remoteRepositories, localRepository, true); if (childProject.getDependencyArtifacts() == null) { childProject.setDependencyArtifacts(childProject.createArtifacts(m_factory, null, null)); } } catch (ProjectBuildingException e) { throw new MojoExecutionException("Unable to build project object for artifact " + artifact, e); } catch (InvalidDependencyVersionException e) { throw new MojoExecutionException("Invalid dependency version for artifact " + artifact); } childProject.setArtifact(artifact); getLog().debug("Child project artifact location: " + childProject.getArtifact().getFile()); if ((Artifact.SCOPE_COMPILE.equals(artifact.getScope())) || (Artifact.SCOPE_RUNTIME.equals(artifact.getScope()))) { BundleInfo subBundleInfo = bundleAll(childProject, maxDepth - 1); if (subBundleInfo != null) { bundleInfo.merge(subBundleInfo); } } else { getLog().debug("Not processing due to scope (" + childProject.getArtifact().getScope() + "): " + childProject.getArtifact()); } } return bundleRoot(project, bundleInfo); }
From source file:org.apache.felix.bundleplugin.BundlePlugin.java
License:Apache License
protected Collection getEmbeddableArtifacts(MavenProject project, Analyzer analyzer) throws MojoExecutionException { final Collection artifacts; String embedTransitive = analyzer.getProperty(DependencyEmbedder.EMBED_TRANSITIVE); if (Boolean.valueOf(embedTransitive).booleanValue()) { // includes transitive dependencies artifacts = project.getArtifacts(); } else {//w w w .ja va 2s .c om // only includes direct dependencies artifacts = project.getDependencyArtifacts(); } return getSelectedDependencies(artifacts); }
From source file:org.apache.geronimo.mavenplugins.car.AbstractCarMojo.java
License:Apache License
protected void getDependencies(MavenProject project, boolean useTransitiveDependencies) throws MojoExecutionException { DependencyTreeResolutionListener listener = new DependencyTreeResolutionListener(getLogger()); DependencyNode rootNode;// www .ja v a 2 s . c o m try { Map managedVersions = project.getManagedVersionMap(); Set dependencyArtifacts = project.getDependencyArtifacts(); if (dependencyArtifacts == null) { dependencyArtifacts = project.createArtifacts(artifactFactory, null, null); } ArtifactResolutionResult result = artifactCollector.collect(dependencyArtifacts, project.getArtifact(), managedVersions, localRepository, project.getRemoteArtifactRepositories(), artifactMetadataSource, null, Collections.singletonList(listener)); this.dependencyArtifacts = result.getArtifacts(); rootNode = listener.getRootNode(); } catch (ArtifactResolutionException exception) { throw new MojoExecutionException("Cannot build project dependency tree", exception); } catch (InvalidDependencyVersionException e) { throw new MojoExecutionException("Invalid dependency version for artifact " + project.getArtifact()); } Scanner scanner = new Scanner(); scanner.scan(rootNode, useTransitiveDependencies); localDependencies = scanner.localDependencies.keySet(); treeListing = scanner.getLog(); }
From source file:org.apache.james.mailet.DefaultDescriptorsExtractor.java
License:Apache License
private void logProjectDependencies(MavenProject project, Log log) { log.debug("Logging project dependencies"); if (log.isDebugEnabled()) { @SuppressWarnings("unchecked") final Set<Artifact> dependencies = project.getDependencyArtifacts(); if (dependencies == null) { log.debug("No project dependencies"); } else {/*from w w w. j ava 2s . c o m*/ for (Artifact artifact : dependencies) { log.debug("DEP: " + artifact); } } } }
From source file:org.apache.sling.maven.slingstart.ModelUtils.java
License:Apache License
/** * Get a resolved Artifact from the coordinates provided * * @return the artifact, which has been resolved. * @throws MojoExecutionException/*from www .j a va 2s .c o m*/ */ public static Artifact getArtifact(final MavenProject project, final MavenSession session, final ArtifactHandlerManager artifactHandlerManager, final ArtifactResolver resolver, final String groupId, final String artifactId, final String version, final String type, final String classifier) throws MojoExecutionException { final Set<Artifact> artifacts = project.getDependencyArtifacts(); for (final Artifact artifact : artifacts) { if (artifact.getGroupId().equals(groupId) && artifact.getArtifactId().equals(artifactId) && artifact.getVersion().equals(version) && artifact.getType().equals(type) && ((classifier == null && artifact.getClassifier() == null) || (classifier != null && classifier.equals(artifact.getClassifier())))) { return artifact; } } final Artifact prjArtifact = new DefaultArtifact(groupId, artifactId, VersionRange.createFromVersion(version), Artifact.SCOPE_PROVIDED, type, classifier, artifactHandlerManager.getArtifactHandler(type)); try { resolver.resolve(prjArtifact, project.getRemoteArtifactRepositories(), session.getLocalRepository()); } catch (final ArtifactResolutionException e) { throw new MojoExecutionException( "Unable to get artifact for " + groupId + ":" + artifactId + ":" + version, e); } catch (final ArtifactNotFoundException e) { throw new MojoExecutionException( "Unable to get artifact for " + groupId + ":" + artifactId + ":" + version, e); } return prjArtifact; }
From source file:org.apache.tuscany.maven.bundle.plugin.BundlesMetaDataBuildMojo.java
License:Apache License
private MavenProject buildProject(Artifact artifact) throws ProjectBuildingException, InvalidDependencyVersionException, ArtifactResolutionException, ArtifactNotFoundException, DependencyTreeBuilderException { MavenProject pomProject = mavenProjectBuilder.buildFromRepository(artifact, this.remoteRepos, this.local); if (pomProject.getDependencyArtifacts() == null) { pomProject.setDependencyArtifacts(pomProject.createArtifacts(factory, null, // Artifact.SCOPE_TEST, new ScopeArtifactFilter(Artifact.SCOPE_TEST))); }/* w w w . j a va2s . c o m*/ if (includeConflictingDepedencies) { pomProject.setArtifacts(getDependencyArtifacts(pomProject)); } else { ArtifactResolutionResult result = resolver.resolveTransitively(pomProject.getDependencyArtifacts(), pomProject.getArtifact(), remoteRepos, local, artifactMetadataSource); pomProject.setArtifacts(result.getArtifacts()); } return pomProject; }
From source file:org.bridje.maven.plugin.ClassPathUtils.java
License:Apache License
public static ClassLoader createClassPath(MavenProject project) throws MalformedURLException, DuplicateRealmException, DependencyResolutionRequiredException { List<String> elements = project.getCompileClasspathElements(); Set<Artifact> artifacts = project.getDependencyArtifacts(); ClassWorld world = new ClassWorld(); ClassRealm newRealm = world.newRealm("projCp", null); for (Artifact artifact : artifacts) { File file = artifact.getFile(); newRealm.addConstituent(file.toURI().toURL()); }//from w w w . j a v a 2s.c o m for (String element : elements) { newRealm.addConstituent(new File(element).toURI().toURL()); } return newRealm.getClassLoader(); }