use of org.apache.maven.shared.dependency.tree.DependencyNode in project intellij-community by JetBrains.
the class Maven2ModelConverter method convertDependencyNodes.
public static List<MavenArtifactNode> convertDependencyNodes(MavenArtifactNode parent, Collection<DependencyNode> nodes, Map<Artifact, MavenArtifact> nativeToConvertedMap, File localRepository) {
List<MavenArtifactNode> result = new ArrayList<MavenArtifactNode>(nodes.size());
for (DependencyNode each : nodes) {
Artifact a = each.getArtifact();
MavenArtifact ma = convertArtifact(a, nativeToConvertedMap, localRepository);
MavenArtifactState state = MavenArtifactState.ADDED;
switch(each.getState()) {
case DependencyNode.INCLUDED:
break;
case DependencyNode.OMITTED_FOR_CONFLICT:
state = MavenArtifactState.CONFLICT;
break;
case DependencyNode.OMITTED_FOR_DUPLICATE:
state = MavenArtifactState.DUPLICATE;
break;
case DependencyNode.OMITTED_FOR_CYCLE:
state = MavenArtifactState.CYCLE;
break;
default:
assert false : "unknown dependency node state: " + each.getState();
}
MavenArtifact relatedMA = each.getRelatedArtifact() == null ? null : convertArtifact(each.getRelatedArtifact(), nativeToConvertedMap, localRepository);
MavenArtifactNode newNode = new MavenArtifactNode(parent, ma, state, relatedMA, each.getOriginalScope(), each.getPremanagedVersion(), each.getPremanagedScope());
newNode.setDependencies(convertDependencyNodes(newNode, each.getChildren(), nativeToConvertedMap, localRepository));
result.add(newNode);
}
return result;
}
use of org.apache.maven.shared.dependency.tree.DependencyNode in project intellij-community by JetBrains.
the class MavenModelConverter method convertDependencyNodes.
public static List<MavenArtifactNode> convertDependencyNodes(MavenArtifactNode parent, Collection<DependencyNode> nodes, Map<Artifact, MavenArtifact> nativeToConvertedMap, File localRepository) {
List<MavenArtifactNode> result = new ArrayList<MavenArtifactNode>(nodes.size());
for (DependencyNode each : nodes) {
Artifact a = each.getArtifact();
MavenArtifact ma = convertArtifact(a, nativeToConvertedMap, localRepository);
MavenArtifactState state = MavenArtifactState.ADDED;
switch(each.getState()) {
case DependencyNode.INCLUDED:
break;
case DependencyNode.OMITTED_FOR_CONFLICT:
state = MavenArtifactState.CONFLICT;
break;
case DependencyNode.OMITTED_FOR_DUPLICATE:
state = MavenArtifactState.DUPLICATE;
break;
case DependencyNode.OMITTED_FOR_CYCLE:
state = MavenArtifactState.CYCLE;
break;
default:
assert false : "unknown dependency node state: " + each.getState();
}
MavenArtifact relatedMA = each.getRelatedArtifact() == null ? null : convertArtifact(each.getRelatedArtifact(), nativeToConvertedMap, localRepository);
MavenArtifactNode newNode = new MavenArtifactNode(parent, ma, state, relatedMA, each.getOriginalScope(), each.getPremanagedVersion(), each.getPremanagedScope());
newNode.setDependencies(convertDependencyNodes(newNode, each.getChildren(), nativeToConvertedMap, localRepository));
result.add(newNode);
}
return result;
}
use of org.apache.maven.shared.dependency.tree.DependencyNode in project camel by apache.
the class SpringBootStarterMojo method filterIncludedArtifacts.
private Set<String> filterIncludedArtifacts(Set<String> artifacts) throws DependencyTreeBuilderException {
Set<String> included = new TreeSet<>();
ArtifactFilter artifactFilter = new ScopeArtifactFilter(null);
DependencyNode node = treeBuilder.buildDependencyTree(project, localRepository, artifactFactory, artifactMetadataSource, artifactFilter, artifactCollector);
CollectingDependencyNodeVisitor visitor = new CollectingDependencyNodeVisitor();
node.accept(visitor);
List<DependencyNode> nodes = visitor.getNodes();
for (DependencyNode dependencyNode : nodes) {
Artifact artifact = dependencyNode.getArtifact();
getLog().debug("Found dependency node: " + artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion() + " - scope=" + artifact.getScope());
if (!Artifact.SCOPE_TEST.equals(artifact.getScope()) && !Artifact.SCOPE_PROVIDED.equals(artifact.getScope())) {
String canonicalName = artifact.getGroupId() + ":" + artifact.getArtifactId();
if (artifacts.contains(canonicalName)) {
getLog().debug(canonicalName + " marked for exclusion");
included.add(canonicalName);
}
}
}
return included;
}
use of org.apache.maven.shared.dependency.tree.DependencyNode in project felix by apache.
the class BundleAllPlugin method bundleAll.
/**
* Bundle a project and its transitive dependencies up to some depth level
*
* @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 (InvalidDependencyVersionException e) {
throw new MojoExecutionException("Invalid dependency version for artifact " + artifact);
} catch (ProjectBuildingException e) {
throw new MojoExecutionException("Unable to build project object for artifact " + artifact, e);
}
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);
}
use of org.apache.maven.shared.dependency.tree.DependencyNode in project fabric8 by jboss-fuse.
the class AbstractProfileMojo method walkTree.
protected void walkTree(DependencyNode node, int level) {
if (node == null) {
getLog().warn("Null node!");
return;
}
getLog().info(indent(level) + node.getArtifact());
List children = node.getChildren();
for (Object child : children) {
if (child instanceof DependencyNode) {
walkTree((DependencyNode) child, level + 1);
} else {
getLog().warn("Unknown class " + child.getClass());
}
}
}
Aggregations