private String getFullArtifactName( DependencyNode node, boolean usePremanaged ) { Artifact artifact = node.getArtifact(); String version = node.getPremanagedVersion(); if ( !usePremanaged || version == null ) { version = uniqueVersions ? artifact.getVersion() : artifact.getBaseVersion(); } return artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + version; }
private String getFullArtifactName( DependencyNode node, boolean usePremanaged ) { Artifact artifact = node.getArtifact(); String version = node.getPremanagedVersion(); if ( !usePremanaged || version == null ) { version = uniqueVersions ? artifact.getVersion() : artifact.getBaseVersion(); } return artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + version; }
private StringBuilder buildTreeString( DependencyNode node ) { List<String> loc = new ArrayList<String>(); DependencyNode currentNode = node; while ( currentNode != null ) { StringBuilder line = new StringBuilder( getFullArtifactName( currentNode, false ) ); if ( currentNode.getPremanagedVersion() != null ) { line.append( " (managed) <-- " ); line.append( getFullArtifactName( currentNode, true ) ); } loc.add( line.toString() ); currentNode = currentNode.getParent(); } Collections.reverse( loc ); StringBuilder builder = new StringBuilder(); for ( int i = 0; i < loc.size(); i++ ) { for ( int j = 0; j < i; j++ ) { builder.append( " " ); } builder.append( "+-" ).append( loc.get( i ) ); builder.append( "\n" ); } return builder; }
private StringBuilder buildTreeString( DependencyNode node ) { List<String> loc = new ArrayList<String>(); DependencyNode currentNode = node; while ( currentNode != null ) { StringBuilder line = new StringBuilder( getFullArtifactName( currentNode, false ) ); if ( currentNode.getPremanagedVersion() != null ) { line.append( " (managed) <-- " ); line.append( getFullArtifactName( currentNode, true ) ); } loc.add( line.toString() ); currentNode = currentNode.getParent(); } Collections.reverse( loc ); StringBuilder builder = new StringBuilder(); for ( int i = 0; i < loc.size(); i++ ) { for ( int j = 0; j < i; j++ ) { builder.append( " " ); } builder.append( "+-" ).append( loc.get( i ) ); builder.append( System.lineSeparator() ); } return builder; }
private ArtifactVersion extractArtifactVersion( boolean uniqueVersions, boolean usePremanagedVersion ) { if ( usePremanagedVersion && node.getPremanagedVersion() != null ) { return new DefaultArtifactVersion( node.getPremanagedVersion() ); } Artifact artifact = node.getArtifact(); String version = uniqueVersions ? artifact.getVersion() : artifact.getBaseVersion(); if ( version != null ) { return new DefaultArtifactVersion( version ); } try { return artifact.getSelectedVersion(); } catch ( OverConstrainedVersionException e ) { throw new RuntimeException( "Version ranges problem with " + node.getArtifact(), e ); } }
private ArtifactVersion extractArtifactVersion( boolean uniqueVersions, boolean usePremanagedVersion ) { if ( usePremanagedVersion && node.getPremanagedVersion() != null ) { return new DefaultArtifactVersion( node.getPremanagedVersion() ); } Artifact artifact = node.getArtifact(); String version = uniqueVersions ? artifact.getVersion() : artifact.getBaseVersion(); if ( version != null ) { return new DefaultArtifactVersion( version ); } try { return artifact.getSelectedVersion(); } catch ( OverConstrainedVersionException e ) { throw new RuntimeException( "Version ranges problem with " + node.getArtifact(), e ); } }
new DefaultDependencyNode( parent, node.getArtifact(), node.getPremanagedVersion(), node.getPremanagedScope(), versionSelectedFromRange );
/** * {@inheritDoc} */ public boolean visit( DependencyNode node ) { // clone the node DependencyNode newNode = new DependencyNode( node.getArtifact(), node.getState(), node.getRelatedArtifact() ); newNode.setOriginalScope( node.getOriginalScope() ); newNode.setFailedUpdateScope( node.getFailedUpdateScope() ); newNode.setPremanagedVersion( node.getPremanagedVersion() ); newNode.setPremanagedScope( node.getPremanagedScope() ); if ( parentNodes.empty() ) { rootNode = newNode; } else { DependencyNode parentNode = parentNodes.peek(); parentNode.addChild( newNode ); } parentNodes.push( newNode ); return true; }
if ( getPremanagedVersion() != null ) appender.append( "version managed from ", getPremanagedVersion() );
/** * {@inheritDoc} */ public int hashCode() { // TODO: probably better using commons-lang HashCodeBuilder int hashCode = 1; hashCode = hashCode * HASH_PRIME + getArtifact().hashCode(); // DefaultArtifact.hashCode does not consider scope hashCode = hashCode * HASH_PRIME + nullHashCode( getArtifact().getScope() ); // TODO: use parent's artifact to prevent recursion - how can we improve this? hashCode = hashCode * HASH_PRIME + nullHashCode( nullGetArtifact( getParent() ) ); hashCode = hashCode * HASH_PRIME + getChildren().hashCode(); hashCode = hashCode * HASH_PRIME + getState(); hashCode = hashCode * HASH_PRIME + nullHashCode( getRelatedArtifact() ); hashCode = hashCode * HASH_PRIME + nullHashCode( getPremanagedVersion() ); hashCode = hashCode * HASH_PRIME + nullHashCode( getPremanagedScope() ); hashCode = hashCode * HASH_PRIME + nullHashCode( getOriginalScope() ); hashCode = hashCode * HASH_PRIME + nullHashCode( getFailedUpdateScope() ); hashCode = hashCode * HASH_PRIME + nullHashCode( getVersionSelectedFromRange() ); hashCode = hashCode * HASH_PRIME + nullHashCode( getAvailableVersions() ); return hashCode; }
@Override public boolean equals( Object object ) { // TODO: probably better using commons-lang EqualsBuilder boolean equal; if ( object instanceof DependencyNode ) { DependencyNode node = (DependencyNode) object; equal = getArtifact().equals( node.getArtifact() ); // DefaultArtifact.hashCode does not consider scope equal &= nullEquals( getArtifact().getScope(), node.getArtifact().getScope() ); // TODO: use parent's artifact to prevent recursion - how can we improve this? equal &= nullEquals( nullGetArtifact( getParent() ), nullGetArtifact( node.getParent() ) ); equal &= getChildren().equals( node.getChildren() ); equal &= getState() == node.getState(); equal &= nullEquals( getRelatedArtifact(), node.getRelatedArtifact() ); equal &= nullEquals( getPremanagedVersion(), node.getPremanagedVersion() ); equal &= nullEquals( getPremanagedScope(), node.getPremanagedScope() ); equal &= nullEquals( getOriginalScope(), node.getOriginalScope() ); equal &= nullEquals( getFailedUpdateScope(), node.getFailedUpdateScope() ); equal &= nullEquals( getVersionSelectedFromRange(), node.getVersionSelectedFromRange() ); equal &= nullEquals( getAvailableVersions(), node.getAvailableVersions() ); } else { equal = false; } return equal; }