use of org.apache.maven.shared.dependency.tree.DependencyNode in project fabric8 by jboss-fuse.
the class AbstractProfileMojo method loadRootDependency.
protected DependencyDTO loadRootDependency() throws DependencyTreeBuilderException {
ArtifactFilter artifactFilter = createResolvingArtifactFilter();
DependencyNode dependencyNode = dependencyTreeBuilder.buildDependencyTree(project, localRepository, artifactFactory, metadataSource, artifactFilter, artifactCollector);
return buildFrom(dependencyNode);
}
use of org.apache.maven.shared.dependency.tree.DependencyNode in project fabric8 by jboss-fuse.
the class AbstractProfileMojo method buildFrom.
private DependencyDTO buildFrom(DependencyNode node) {
Artifact artifact = node.getArtifact();
if (artifact != null) {
DependencyDTO answer = new DependencyDTO();
answer.setGroupId(artifact.getGroupId());
answer.setArtifactId(artifact.getArtifactId());
if (artifact.isSnapshot() && !uniqueVersion) {
answer.setVersion(artifact.getBaseVersion());
} else {
answer.setVersion(artifact.getVersion());
}
answer.setClassifier(artifact.getClassifier());
String scope = artifact.getScope();
answer.setScope(scope);
answer.setType(artifact.getType());
// so lets ignore this for the maven project's artifact
if (artifact.getClassifier() == null && "jar".equals(artifact.getType())) {
if (project.getArtifact().equals(artifact)) {
getLog().debug("Ignoring bundle check on the maven project artifact: " + artifact + " as this causes issues with the maven-install-plugin and we can assume the project packaging is accurate");
} else {
try {
ArtifactResolutionRequest request = new ArtifactResolutionRequest();
request.setArtifact(artifact);
request.setRemoteRepositories(remoteRepositories);
request.setLocalRepository(localRepository);
resolver.resolve(request);
JarInputStream jis = new JarInputStream(new FileInputStream(artifact.getFile()));
Manifest man = jis.getManifest();
String bsn = man.getMainAttributes().getValue(Constants.BUNDLE_SYMBOLICNAME);
if (bsn != null) {
answer.setType("bundle");
} else {
// Try to find a matching servicemix bundle for it
/*
Map<String, String> bundles = getAllServiceMixBundles();
getLog().debug("Trying to find a matching bundle for " + artifact);
String match = bundles.get(artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion());
if (match != null) {
String[] parts = match.split(":");
answer.setGroupId(parts[0]);
answer.setArtifactId(parts[1]);
answer.setVersion(parts[2]);
getLog().info("Replacing artifact " + artifact + " with servicemix bundle " + match);
}
*/
}
} catch (Exception e) {
getLog().debug("Error checking artifact type for " + artifact, e);
}
}
}
answer.setOptional(artifact.isOptional());
String type = answer.getType();
if (type != null && type.equals("pom")) {
getLog().debug("Ignoring pom.xml for " + answer);
return null;
}
int state = node.getState();
if (state != DependencyNode.INCLUDED) {
getLog().debug("Ignoring " + node);
return null;
}
if (isWarProject()) {
if (scope != null && !scope.equals("provided")) {
getLog().debug("WAR packaging so ignoring non-provided scope " + scope + " for " + node);
return null;
}
}
List children = node.getChildren();
for (Object child : children) {
if (child instanceof DependencyNode) {
DependencyNode childNode = (DependencyNode) child;
if (childNode.getState() == DependencyNode.INCLUDED) {
String childScope = childNode.getArtifact().getScope();
if (!"test".equals(childScope) && !"provided".equals(childScope)) {
DependencyDTO childDTO = buildFrom(childNode);
if (childDTO != null) {
answer.addChild(childDTO);
}
} else {
getLog().debug("Ignoring artifact " + childNode.getArtifact() + " with scope " + childScope);
}
}
}
}
return answer;
}
return null;
}
use of org.apache.maven.shared.dependency.tree.DependencyNode in project maven-plugins by apache.
the class DependencyConvergenceReport method getProjectNodes.
private List<DependencyNode> getProjectNodes(List<ReverseDependencyLink> depList) {
List<DependencyNode> projectNodes = new ArrayList<DependencyNode>();
for (ReverseDependencyLink depLink : depList) {
MavenProject project = depLink.getProject();
DependencyNode projectNode = this.projectMap.get(project);
if (projectNode != null && !projectNodes.contains(projectNode)) {
projectNodes.add(projectNode);
}
}
return projectNodes;
}
use of org.apache.maven.shared.dependency.tree.DependencyNode in project maven-plugins by apache.
the class DependencyConvergenceReport method analyzeDependencyTree.
/**
* Produce a DependencyAnalyzeResult, it contains conflicting dependencies map, snapshot dependencies map and all
* dependencies map. Map structure is the relationships between dependencies (its groupId:artifactId) and reactor
* projects. This is the structure of the Map:
*
* <pre>
* +--------------------+----------------------------------+---------------|
* | key | value |
* +--------------------+----------------------------------+---------------|
* | groupId:artifactId | A List of ReverseDependencyLinks |
* | of a dependency | which each look like this: |
* | | +------------+-----------------+-----------------|
* | | | dependency | reactor project | dependency node |
* | | +------------+-----------------+-----------------|
* +--------------------+--------------------------------------------------|
* </pre>
*
* @return DependencyAnalyzeResult contains conflicting dependencies map, snapshot dependencies map and all
* dependencies map.
* @throws MavenReportException
*/
private DependencyAnalyzeResult analyzeDependencyTree() throws MavenReportException {
Map<String, List<ReverseDependencyLink>> conflictingDependencyMap = new TreeMap<String, List<ReverseDependencyLink>>();
Map<String, List<ReverseDependencyLink>> allDependencies = new TreeMap<String, List<ReverseDependencyLink>>();
for (MavenProject reactorProject : reactorProjects) {
DependencyNode node = getNode(reactorProject);
this.projectMap.put(reactorProject, node);
getConflictingDependencyMap(conflictingDependencyMap, reactorProject, node);
getAllDependencyMap(allDependencies, reactorProject, node);
}
return populateDependencyAnalyzeResult(conflictingDependencyMap, allDependencies);
}
use of org.apache.maven.shared.dependency.tree.DependencyNode in project maven-plugins by apache.
the class SinkSerializingDependencyNodeVisitor method isLast.
/**
* Gets whether the specified dependency node is the last of its siblings.
*
* @param node the dependency node to check
* @return <code>true</code> if the specified dependency node is the last of its last siblings
*/
private boolean isLast(DependencyNode node) {
// TODO: remove node argument and calculate from visitor calls only
DependencyNode parent = node.getParent();
boolean last;
if (parent == null) {
last = true;
} else {
List<DependencyNode> siblings = parent.getChildren();
last = (siblings.indexOf(node) == siblings.size() - 1);
}
return last;
}
Aggregations