FELIX-1148: apply local patch for MSHARED-101
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@810669 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/bundleplugin/pom.xml b/bundleplugin/pom.xml
index ba0a4d4..cfc4ab8 100644
--- a/bundleplugin/pom.xml
+++ b/bundleplugin/pom.xml
@@ -109,6 +109,11 @@
<version>2.0.7</version>
</dependency>
<dependency>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-dependency-tree</artifactId>
+ <version>1.2</version>
+ </dependency>
+ <dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-provider-api</artifactId>
<version>1.0-beta-2</version>
diff --git a/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/DefaultDependencyTreeBuilder.java b/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/DefaultDependencyTreeBuilder.java
deleted file mode 100644
index bfce140..0000000
--- a/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/DefaultDependencyTreeBuilder.java
+++ /dev/null
@@ -1,120 +0,0 @@
-package org.apache.maven.shared.dependency.tree;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.Collections;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.maven.artifact.factory.ArtifactFactory;
-import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.resolver.ArtifactCollector;
-import org.apache.maven.artifact.resolver.ArtifactResolutionException;
-import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
-import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.project.artifact.InvalidDependencyVersionException;
-import org.apache.maven.shared.dependency.tree.traversal.CollectingDependencyNodeVisitor;
-import org.codehaus.plexus.logging.AbstractLogEnabled;
-
-/**
- * Default implementation of <code>DependencyTreeBuilder</code>.
- *
- * @author Edwin Punzalan
- * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
- * @version $Id: DefaultDependencyTreeBuilder.java 661727 2008-05-30 14:21:49Z bentmann $
- * @plexus.component role="org.apache.maven.shared.dependency.tree.DependencyTreeBuilder"
- * @see DependencyTreeBuilder
- */
-public class DefaultDependencyTreeBuilder extends AbstractLogEnabled implements DependencyTreeBuilder
-{
- // fields -----------------------------------------------------------------
-
- private ArtifactResolutionResult result;
-
- // DependencyTreeBuilder methods ------------------------------------------
-
- /**
- * {@inheritDoc}
- *
- * @deprecated
- */
- public DependencyTree buildDependencyTree( MavenProject project, ArtifactRepository repository,
- ArtifactFactory factory, ArtifactMetadataSource metadataSource,
- ArtifactCollector collector ) throws DependencyTreeBuilderException
- {
- DependencyNode rootNode = buildDependencyTree( project, repository, factory, metadataSource, null, collector );
-
- CollectingDependencyNodeVisitor collectingVisitor = new CollectingDependencyNodeVisitor();
- rootNode.accept( collectingVisitor );
-
- return new DependencyTree( rootNode, collectingVisitor.getNodes() );
- }
-
- /**
- * {@inheritDoc}
- */
- public DependencyNode buildDependencyTree( MavenProject project, ArtifactRepository repository,
- ArtifactFactory factory, ArtifactMetadataSource metadataSource,
- ArtifactFilter filter, ArtifactCollector collector )
- throws DependencyTreeBuilderException
- {
- DependencyTreeResolutionListener listener = new DependencyTreeResolutionListener( getLogger() );
-
- try
- {
- Map managedVersions = project.getManagedVersionMap();
-
- Set dependencyArtifacts = project.getDependencyArtifacts();
-
- if ( dependencyArtifacts == null )
- {
- dependencyArtifacts = project.createArtifacts( factory, null, null );
- }
-
- getLogger().debug( "Dependency tree resolution listener events:" );
-
- // TODO: note that filter does not get applied due to MNG-3236
-
- result = collector.collect( dependencyArtifacts, project.getArtifact(), managedVersions, repository,
- project.getRemoteArtifactRepositories(), metadataSource, filter,
- Collections.singletonList( listener ) );
-
- return listener.getRootNode();
- }
- catch ( ArtifactResolutionException exception )
- {
- throw new DependencyTreeBuilderException( "Cannot build project dependency tree", exception );
- }
- catch ( InvalidDependencyVersionException e )
- {
- throw new DependencyTreeBuilderException( "Invalid dependency version for artifact "
- + project.getArtifact() );
- }
- }
-
- // protected methods ------------------------------------------------------
-
- protected ArtifactResolutionResult getArtifactResolutionResult()
- {
- return result;
- }
-}
diff --git a/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/DependencyNode.java b/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/DependencyNode.java
deleted file mode 100644
index e113c1b..0000000
--- a/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/DependencyNode.java
+++ /dev/null
@@ -1,904 +0,0 @@
-package org.apache.maven.shared.dependency.tree;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.versioning.VersionRange;
-import org.apache.maven.shared.dependency.tree.traversal.DependencyNodeVisitor;
-import org.apache.maven.shared.dependency.tree.traversal.SerializingDependencyNodeVisitor;
-
-/**
- * Represents an artifact node within a Maven project's dependency tree.
- *
- * @author Edwin Punzalan
- * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
- * @version $Id: DependencyNode.java 661727 2008-05-30 14:21:49Z bentmann $
- */
-public class DependencyNode
-{
- // constants --------------------------------------------------------------
-
- /**
- * State that represents an included dependency node.
- *
- * @since 1.1
- */
- public static final int INCLUDED = 0;
-
- /**
- * State that represents a dependency node that has been omitted for duplicating another dependency node.
- *
- * @since 1.1
- */
- public static final int OMITTED_FOR_DUPLICATE = 1;
-
- /**
- * State that represents a dependency node that has been omitted for conflicting with another dependency node.
- *
- * @since 1.1
- */
- public static final int OMITTED_FOR_CONFLICT = 2;
-
- /**
- * State that represents a dependency node that has been omitted for introducing a cycle into the dependency tree.
- *
- * @since 1.1
- */
- public static final int OMITTED_FOR_CYCLE = 3;
-
- // classes ----------------------------------------------------------------
-
- /**
- * Utility class to concatenate a number of parameters with separator tokens.
- */
- private static class ItemAppender
- {
- private StringBuffer buffer;
-
- private String startToken;
-
- private String separatorToken;
-
- private String endToken;
-
- private boolean appended;
-
- public ItemAppender( StringBuffer buffer, String startToken, String separatorToken, String endToken )
- {
- this.buffer = buffer;
- this.startToken = startToken;
- this.separatorToken = separatorToken;
- this.endToken = endToken;
-
- appended = false;
- }
-
- public ItemAppender append( String item )
- {
- appendToken();
-
- buffer.append( item );
-
- return this;
- }
-
- public ItemAppender append( String item1, String item2 )
- {
- appendToken();
-
- buffer.append( item1 ).append( item2 );
-
- return this;
- }
-
- public void flush()
- {
- if ( appended )
- {
- buffer.append( endToken );
-
- appended = false;
- }
- }
-
- private void appendToken()
- {
- buffer.append( appended ? separatorToken : startToken );
-
- appended = true;
- }
- }
-
- // fields -----------------------------------------------------------------
-
- /**
- * The artifact that is attached to this dependency node.
- */
- private final Artifact artifact;
-
- /**
- * The list of child dependency nodes of this dependency node.
- */
- private final List children;
-
- /**
- * The parent dependency node of this dependency node.
- */
- private DependencyNode parent;
-
- /**
- * The state of this dependency node. This can be either <code>INCLUDED</code>,
- * <code>OMITTED_FOR_DUPLICATE</code>, <code>OMITTED_FOR_CONFLICT</code> or <code>OMITTED_FOR_CYCLE</code>.
- *
- * @see #INCLUDED
- * @see #OMITTED_FOR_DUPLICATE
- * @see #OMITTED_FOR_CONFLICT
- * @see #OMITTED_FOR_CYCLE
- */
- private int state;
-
- /**
- * The artifact related to the state of this dependency node. For dependency nodes with a state of
- * <code>OMITTED_FOR_DUPLICATE</code> or <code>OMITTED_FOR_CONFLICT</code>, this represents the artifact that
- * was conflicted with. For dependency nodes of other states, this is always <code>null</code>.
- */
- private Artifact relatedArtifact;
-
- /**
- * The scope of this node's artifact before it was updated due to conflicts, or <code>null</code> if the artifact
- * scope has not been updated.
- */
- private String originalScope;
-
- /**
- * The scope that this node's artifact was attempted to be updated to due to conflicts, or <code>null</code> if
- * the artifact scope has not failed being updated.
- */
- private String failedUpdateScope;
-
- /**
- * The version of this node's artifact before it was updated by dependency management, or <code>null</code> if the
- * artifact version has not been managed.
- */
- private String premanagedVersion;
-
- /**
- * The scope of this node's artifact before it was updated by dependency management, or <code>null</code> if the
- * artifact scope has not been managed.
- */
- private String premanagedScope;
-
- private VersionRange versionSelectedFromRange;
-
- private List availableVersions;
-
- // constructors -----------------------------------------------------------
-
- /**
- * Creates a new dependency node for the specified artifact with an included state.
- *
- * @param artifact
- * the artifact attached to the new dependency node
- * @throws IllegalArgumentException
- * if the parameter constraints were violated
- * @since 1.1
- */
- public DependencyNode( Artifact artifact )
- {
- this( artifact, INCLUDED );
- }
-
- /**
- * Creates a new dependency node for the specified artifact with the specified state.
- *
- * @param artifact
- * the artifact attached to the new dependency node
- * @param state
- * the state of the new dependency node. This can be either <code>INCLUDED</code> or
- * <code>OMITTED_FOR_CYCLE</code>.
- * @throws IllegalArgumentException
- * if the parameter constraints were violated
- * @since 1.1
- */
- public DependencyNode( Artifact artifact, int state )
- {
- this( artifact, state, null );
- }
-
- /**
- * Creates a new dependency node for the specified artifact with the specified state and related artifact.
- *
- * @param artifact
- * the artifact attached to the new dependency node
- * @param state
- * the state of the new dependency node. This can be either <code>INCLUDED</code>,
- * <code>OMITTED_FOR_DUPLICATE</code>, <code>OMITTED_FOR_CONFLICT</code> or
- * <code>OMITTED_FOR_CYCLE</code>.
- * @param relatedArtifact
- * the artifact related to the state of this dependency node. For dependency nodes with a state of
- * <code>OMITTED_FOR_DUPLICATE</code> or <code>OMITTED_FOR_CONFLICT</code>, this represents the
- * artifact that was conflicted with. For dependency nodes of other states, this should always be
- * <code>null</code>.
- * @throws IllegalArgumentException
- * if the parameter constraints were violated
- * @since 1.1
- */
- public DependencyNode( Artifact artifact, int state, Artifact relatedArtifact )
- {
- if ( artifact == null )
- {
- throw new IllegalArgumentException( "artifact cannot be null" );
- }
-
- if ( state < INCLUDED || state > OMITTED_FOR_CYCLE )
- {
- throw new IllegalArgumentException( "Unknown state: " + state );
- }
-
- boolean requiresRelatedArtifact = ( state == OMITTED_FOR_DUPLICATE || state == OMITTED_FOR_CONFLICT );
-
- if ( requiresRelatedArtifact && relatedArtifact == null )
- {
- throw new IllegalArgumentException( "Related artifact is required for states "
- + "OMITTED_FOR_DUPLICATE and OMITTED_FOR_CONFLICT" );
- }
-
- if ( !requiresRelatedArtifact && relatedArtifact != null )
- {
- throw new IllegalArgumentException( "Related artifact is only required for states "
- + "OMITTED_FOR_DUPLICATE and OMITTED_FOR_CONFLICT" );
- }
-
- this.artifact = artifact;
- this.state = state;
- this.relatedArtifact = relatedArtifact;
-
- children = new ArrayList();
- }
-
- /**
- * Creates a new dependency node.
- *
- * @deprecated As of 1.1, replaced by {@link #DependencyNode(Artifact, int, Artifact)}
- */
- DependencyNode()
- {
- artifact = null;
- children = new ArrayList();
- }
-
- // public methods ---------------------------------------------------------
-
- /**
- * Applies the specified dependency node visitor to this dependency node and its children.
- *
- * @param visitor
- * the dependency node visitor to use
- * @return the visitor result of ending the visit to this node
- * @since 1.1
- */
- public boolean accept( DependencyNodeVisitor visitor )
- {
- if ( visitor.visit( this ) )
- {
- boolean visiting = true;
-
- for ( Iterator iterator = getChildren().iterator(); visiting && iterator.hasNext(); )
- {
- DependencyNode child = (DependencyNode) iterator.next();
-
- visiting = child.accept( visitor );
- }
- }
-
- return visitor.endVisit( this );
- }
-
- /**
- * Adds the specified dependency node to this dependency node's children.
- *
- * @param child
- * the child dependency node to add
- * @since 1.1
- */
- public void addChild( DependencyNode child )
- {
- children.add( child );
- child.parent = this;
- }
-
- /**
- * Removes the specified dependency node from this dependency node's children.
- *
- * @param child
- * the child dependency node to remove
- * @since 1.1
- */
- public void removeChild( DependencyNode child )
- {
- children.remove( child );
- child.parent = null;
- }
-
- /**
- * Gets the parent dependency node of this dependency node.
- *
- * @return the parent dependency node
- */
- public DependencyNode getParent()
- {
- return parent;
- }
-
- /**
- * Gets the artifact attached to this dependency node.
- *
- * @return the artifact
- */
- public Artifact getArtifact()
- {
- return artifact;
- }
-
- /**
- * Gets the depth of this dependency node within its hierarchy.
- *
- * @return the depth
- * @deprecated As of 1.1, depth is computed by node hierarchy. With the introduction of node
- * visitors and filters this method can give misleading results. For example, consider
- * serialising a tree with a filter using a visitor: this method would return the
- * unfiltered depth of a node, whereas the correct depth would be calculated by the
- * visitor.
- */
- public int getDepth()
- {
- int depth = 0;
-
- DependencyNode node = getParent();
-
- while ( node != null )
- {
- depth++;
-
- node = node.getParent();
- }
-
- return depth;
- }
-
- /**
- * Gets the list of child dependency nodes of this dependency node.
- *
- * @return the list of child dependency nodes
- */
- public List getChildren()
- {
- return Collections.unmodifiableList( children );
- }
-
- public boolean hasChildren()
- {
- return children.size() > 0;
- }
-
- /**
- * Gets the state of this dependency node.
- *
- * @return the state: either <code>INCLUDED</code>, <code>OMITTED_FOR_DUPLICATE</code>,
- * <code>OMITTED_FOR_CONFLICT</code> or <code>OMITTED_FOR_CYCLE</code>.
- * @since 1.1
- */
- public int getState()
- {
- return state;
- }
-
- /**
- * Gets the artifact related to the state of this dependency node. For dependency nodes with a state of
- * <code>OMITTED_FOR_CONFLICT</code>, this represents the artifact that was conflicted with. For dependency nodes
- * of other states, this is always <code>null</code>.
- *
- * @return the related artifact
- * @since 1.1
- */
- public Artifact getRelatedArtifact()
- {
- return relatedArtifact;
- }
-
- /**
- * Gets the scope of this node's artifact before it was updated due to conflicts.
- *
- * @return the original scope, or <code>null</code> if the artifact scope has not been updated
- * @since 1.1
- */
- public String getOriginalScope()
- {
- return originalScope;
- }
-
- /**
- * Sets the scope of this node's artifact before it was updated due to conflicts.
- *
- * @param originalScope
- * the original scope, or <code>null</code> if the artifact scope has not been updated
- * @since 1.1
- */
- public void setOriginalScope( String originalScope )
- {
- this.originalScope = originalScope;
- }
-
- /**
- * Gets the scope that this node's artifact was attempted to be updated to due to conflicts.
- *
- * @return the failed update scope, or <code>null</code> if the artifact scope has not failed being updated
- * @since 1.1
- */
- public String getFailedUpdateScope()
- {
- return failedUpdateScope;
- }
-
- /**
- * Sets the scope that this node's artifact was attempted to be updated to due to conflicts.
- *
- * @param failedUpdateScope
- * the failed update scope, or <code>null</code> if the artifact scope has not failed being updated
- * @since 1.1
- */
- public void setFailedUpdateScope( String failedUpdateScope )
- {
- this.failedUpdateScope = failedUpdateScope;
- }
-
- /**
- * Gets the version of this node's artifact before it was updated by dependency management.
- *
- * @return the premanaged version, or <code>null</code> if the artifact version has not been managed
- * @since 1.1
- */
- public String getPremanagedVersion()
- {
- return premanagedVersion;
- }
-
- /**
- * Sets the version of this node's artifact before it was updated by dependency management.
- *
- * @param premanagedVersion
- * the premanaged version, or <code>null</code> if the artifact version has not been managed
- * @since 1.1
- */
- public void setPremanagedVersion( String premanagedVersion )
- {
- this.premanagedVersion = premanagedVersion;
- }
-
- /**
- * Gets the scope of this node's artifact before it was updated by dependency management.
- *
- * @return the premanaged scope, or <code>null</code> if the artifact scope has not been managed
- * @since 1.1
- */
- public String getPremanagedScope()
- {
- return premanagedScope;
- }
-
- /**
- * Sets the scope of this node's artifact before it was updated by dependency management.
- *
- * @param premanagedScope
- * the premanaged scope, or <code>null</code> if the artifact scope has not been managed
- * @since 1.1
- */
- public void setPremanagedScope( String premanagedScope )
- {
- this.premanagedScope = premanagedScope;
- }
-
- /**
- * If the version was selected from a range this method will return the range.
- *
- * @return the version range before a version was selected, or <code>null</code> if the artifact had a explicit
- * version.
- * @since 1.2
- */
- public VersionRange getVersionSelectedFromRange()
- {
- return versionSelectedFromRange;
- }
-
- public void setVersionSelectedFromRange( VersionRange versionSelectedFromRange )
- {
- this.versionSelectedFromRange = versionSelectedFromRange;
- }
-
- /**
- * If the version was selected from a range this method will return the available versions when making the decision.
- *
- * @return {@link List} < {@link String} > the versions available when a version was selected from a range, or
- * <code>null</code> if the artifact had a explicit version.
- * @since 1.2
- */
- public List getAvailableVersions()
- {
- return availableVersions;
- }
-
- public void setAvailableVersions( List availableVersions )
- {
- this.availableVersions = availableVersions;
- }
-
- /**
- * Changes the state of this dependency node to be omitted for conflict or duplication, depending on the specified
- * related artifact.
- *
- * <p>
- * If the related artifact has a version equal to this dependency node's artifact, then this dependency node's state
- * is changed to <code>OMITTED_FOR_DUPLICATE</code>, otherwise it is changed to <code>OMITTED_FOR_CONFLICT</code>.
- * Omitting this dependency node also removes all of its children.
- * </p>
- *
- * @param relatedArtifact
- * the artifact that this dependency node conflicted with
- * @throws IllegalStateException
- * if this dependency node's state is not <code>INCLUDED</code>
- * @throws IllegalArgumentException
- * if the related artifact was <code>null</code> or had a different dependency conflict id to this
- * dependency node's artifact
- * @see #OMITTED_FOR_DUPLICATE
- * @see #OMITTED_FOR_CONFLICT
- * @since 1.1
- */
- public void omitForConflict( Artifact relatedArtifact )
- {
- if ( getState() != INCLUDED )
- {
- throw new IllegalStateException( "Only INCLUDED dependency nodes can be omitted for conflict" );
- }
-
- if ( relatedArtifact == null )
- {
- throw new IllegalArgumentException( "Related artifact cannot be null" );
- }
-
- if ( !relatedArtifact.getDependencyConflictId().equals( getArtifact().getDependencyConflictId() ) )
- {
- throw new IllegalArgumentException( "Related artifact has a different dependency conflict id" );
- }
-
- this.relatedArtifact = relatedArtifact;
-
- boolean duplicate = false;
- if ( getArtifact().getVersion() != null )
- {
- duplicate = getArtifact().getVersion().equals( relatedArtifact.getVersion() );
- }
- else if ( getArtifact().getVersionRange() != null )
- {
- duplicate = getArtifact().getVersionRange().equals( relatedArtifact.getVersionRange() );
- }
- else
- {
- throw new RuntimeException( "Artifact version and version range is null: " + getArtifact() );
- }
-
- state = duplicate ? OMITTED_FOR_DUPLICATE : OMITTED_FOR_CONFLICT;
-
- removeAllChildren();
- }
-
- /**
- * Changes the state of this dependency node to be omitted for a cycle in the dependency tree.
- *
- * <p>
- * Omitting this node sets its state to <code>OMITTED_FOR_CYCLE</code> and removes all of its children.
- * </p>
- *
- * @throws IllegalStateException
- * if this dependency node's state is not <code>INCLUDED</code>
- * @see #OMITTED_FOR_CYCLE
- * @since 1.1
- */
- public void omitForCycle()
- {
- if ( getState() != INCLUDED )
- {
- throw new IllegalStateException( "Only INCLUDED dependency nodes can be omitted for cycle" );
- }
-
- state = OMITTED_FOR_CYCLE;
-
- removeAllChildren();
- }
-
- /**
- * Gets an iterator that returns this dependency node and it's children in preorder traversal.
- *
- * @return the preorder traversal iterator
- * @see #preorderIterator()
- */
- public Iterator iterator()
- {
- return preorderIterator();
- }
-
- /**
- * Gets an iterator that returns this dependency node and it's children in preorder traversal.
- *
- * @return the preorder traversal iterator
- * @see DependencyTreePreorderIterator
- */
- public Iterator preorderIterator()
- {
- return new DependencyTreePreorderIterator( this );
- }
-
- /**
- * Gets an iterator that returns this dependency node and it's children in postorder traversal.
- *
- * @return the postorder traversal iterator
- * @see DependencyTreeInverseIterator
- */
- public Iterator inverseIterator()
- {
- return new DependencyTreeInverseIterator( this );
- }
-
- /**
- * Returns a string representation of this dependency node.
- *
- * @return the string representation
- * @see #toString()
- * @since 1.1
- */
- public String toNodeString()
- {
- StringBuffer buffer = new StringBuffer();
-
- boolean included = ( getState() == INCLUDED );
-
- if ( !included )
- {
- buffer.append( '(' );
- }
-
- buffer.append( artifact );
-
- ItemAppender appender = new ItemAppender( buffer, included ? " (" : " - ", "; ", included ? ")" : "" );
-
- if ( getPremanagedVersion() != null )
- {
- appender.append( "version managed from ", getPremanagedVersion() );
- }
-
- if ( getPremanagedScope() != null )
- {
- appender.append( "scope managed from ", getPremanagedScope() );
- }
-
- if ( getOriginalScope() != null )
- {
- appender.append( "scope updated from ", getOriginalScope() );
- }
-
- if ( getFailedUpdateScope() != null )
- {
- appender.append( "scope not updated to ", getFailedUpdateScope() );
- }
-
- if ( getVersionSelectedFromRange() != null )
- {
- appender.append( "version selected from range ", getVersionSelectedFromRange().toString() );
- appender.append( "available versions ", getAvailableVersions().toString() );
- }
-
- switch ( state )
- {
- case INCLUDED:
- break;
-
- case OMITTED_FOR_DUPLICATE:
- appender.append( "omitted for duplicate" );
- break;
-
- case OMITTED_FOR_CONFLICT:
- appender.append( "omitted for conflict with ", relatedArtifact.getVersion() );
- break;
-
- case OMITTED_FOR_CYCLE:
- appender.append( "omitted for cycle" );
- break;
- }
-
- appender.flush();
-
- if ( !included )
- {
- buffer.append( ')' );
- }
-
- return buffer.toString();
- }
-
- /**
- * Returns a string representation of this dependency node and its children, indented to the specified depth.
- *
- * <p>
- * As of 1.1, this method ignores the indentation depth and simply delegates to <code>toString()</code>.
- * </p>
- *
- * @param indentDepth
- * the indentation depth
- * @return the string representation
- * @deprecated As of 1.1, replaced by {@link #toString()}
- */
- public String toString( int indentDepth )
- {
- return toString();
- }
-
- // Object methods ---------------------------------------------------------
-
- /**
- * {@inheritDoc}
- */
- public int hashCode()
- {
- // TODO: probably better using commons-lang HashCodeBuilder
-
- int hashCode = 1;
-
- hashCode = hashCode * 31 + getArtifact().hashCode();
- // DefaultArtifact.hashCode does not consider scope
- hashCode = hashCode * 31 + nullHashCode( getArtifact().getScope() );
-
- // TODO: use parent's artifact to prevent recursion - how can we improve this?
- hashCode = hashCode * 31 + nullHashCode( nullGetArtifact( getParent() ) );
-
- hashCode = hashCode * 31 + getChildren().hashCode();
- hashCode = hashCode * 31 + getState();
- hashCode = hashCode * 31 + nullHashCode( getRelatedArtifact() );
- hashCode = hashCode * 31 + nullHashCode( getPremanagedVersion() );
- hashCode = hashCode * 31 + nullHashCode( getPremanagedScope() );
- hashCode = hashCode * 31 + nullHashCode( getOriginalScope() );
- hashCode = hashCode * 31 + nullHashCode( getFailedUpdateScope() );
- hashCode = hashCode * 31 + nullHashCode( getVersionSelectedFromRange() );
- hashCode = hashCode * 31 + nullHashCode( getAvailableVersions() );
-
- return hashCode;
- }
-
- /**
- * {@inheritDoc}
- */
- 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;
- }
-
- /**
- * Returns a string representation of this dependency node and its children.
- *
- * @return the string representation
- * @see #toNodeString()
- * @see java.lang.Object#toString()
- */
- public String toString()
- {
- StringWriter writer = new StringWriter();
- accept( new SerializingDependencyNodeVisitor( writer ) );
- return writer.toString();
- }
-
- // private methods --------------------------------------------------------
-
- /**
- * Removes all of this dependency node's children.
- */
- private void removeAllChildren()
- {
- for ( Iterator iterator = children.iterator(); iterator.hasNext(); )
- {
- DependencyNode child = (DependencyNode) iterator.next();
-
- child.parent = null;
- }
-
- children.clear();
- }
-
- /**
- * Computes a hash-code for the specified object.
- *
- * @param a
- * the object to compute a hash-code for, possibly <code>null</code>
- * @return the computed hash-code
- */
- private int nullHashCode( Object a )
- {
- return ( a == null ) ? 0 : a.hashCode();
- }
-
- /**
- * Gets whether the specified objects are equal.
- *
- * @param a
- * the first object to compare, possibly <code>null</code>
- * @param b
- * the second object to compare, possibly <code>null</code>
- * @return <code>true</code> if the specified objects are equal
- */
- private boolean nullEquals( Object a, Object b )
- {
- return ( a == null ? b == null : a.equals( b ) );
- }
-
- /**
- * Gets the artifact for the specified node.
- *
- * @param node
- * the dependency node, possibly <code>null</code>
- * @return the node's artifact, or <code>null</code> if the specified node was <code>null</code>
- */
- private static Artifact nullGetArtifact( DependencyNode node )
- {
- return ( node != null ) ? node.getArtifact() : null;
- }
-}
diff --git a/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTree.java b/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTree.java
deleted file mode 100644
index 921c3be..0000000
--- a/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTree.java
+++ /dev/null
@@ -1,110 +0,0 @@
-package org.apache.maven.shared.dependency.tree;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * Represents a Maven project's dependency tree.
- *
- * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
- * @version $Id: DependencyTree.java 661727 2008-05-30 14:21:49Z bentmann $
- * @deprecated As of 1.1, replaced by the dependency tree root {@link DependencyNode}
- */
-public class DependencyTree
-{
- // fields -----------------------------------------------------------------
-
- private final DependencyNode rootNode;
-
- private final Collection nodes;
-
- // constructors -----------------------------------------------------------
-
- /**
- * Create a tree initialized to the arguments
- *
- * @param rootNode
- * @param nodes
- */
- public DependencyTree( DependencyNode rootNode, Collection nodes )
- {
- this.rootNode = rootNode;
- this.nodes = nodes;
- }
-
- // public methods ---------------------------------------------------------
-
- public DependencyNode getRootNode()
- {
- return rootNode;
- }
-
- public Collection getNodes()
- {
- return nodes;
- }
-
- public List getArtifacts()
- {
- List artifacts = new ArrayList();
-
- Iterator it = getNodes().iterator();
- while ( it.hasNext() )
- {
- DependencyNode node = (DependencyNode) it.next();
- artifacts.add( node.getArtifact() );
- }
-
- return artifacts;
- }
-
- public String toString()
- {
- return getRootNode().toString();
- }
-
- /**
- * @see DependencyNode#iterator()
- */
- public Iterator iterator()
- {
- return getRootNode().iterator();
- }
-
- /**
- * @see DependencyNode#preorderIterator()
- */
- public Iterator preorderIterator()
- {
- return getRootNode().preorderIterator();
- }
-
- /**
- * @see DependencyNode#inverseIterator()
- */
- public Iterator inverseIterator()
- {
- return getRootNode().inverseIterator();
- }
-}
diff --git a/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreeBuilder.java b/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreeBuilder.java
deleted file mode 100644
index 166c2a8..0000000
--- a/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreeBuilder.java
+++ /dev/null
@@ -1,92 +0,0 @@
-package org.apache.maven.shared.dependency.tree;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.artifact.factory.ArtifactFactory;
-import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.resolver.ArtifactCollector;
-import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
-import org.apache.maven.project.MavenProject;
-
-/**
- * Builds a tree of dependencies for a given Maven project.
- *
- * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
- * @version $Id: DependencyTreeBuilder.java 661727 2008-05-30 14:21:49Z bentmann $
- */
-public interface DependencyTreeBuilder
-{
- // fields -----------------------------------------------------------------
-
- /**
- * The plexus role for this component.
- */
- String ROLE = DependencyTreeBuilder.class.getName();
-
- // public methods ---------------------------------------------------------
-
- /**
- * Builds a tree of dependencies for the specified Maven project.
- *
- * @param project
- * the Maven project
- * @param repository
- * the artifact repository to resolve against
- * @param factory
- * the artifact factory to use
- * @param metadataSource
- * the artifact metadata source to use
- * @param collector
- * the artifact collector to use
- * @return the dependency tree of the specified Maven project
- * @throws DependencyTreeBuilderException
- * if the dependency tree cannot be resolved
- * @deprecated As of 1.1, replaced by
- * {@link #buildDependencyTree(MavenProject, ArtifactRepository, ArtifactFactory, ArtifactMetadataSource, ArtifactFilter, ArtifactCollector)}
- */
- DependencyTree buildDependencyTree( MavenProject project, ArtifactRepository repository, ArtifactFactory factory,
- ArtifactMetadataSource metadataSource, ArtifactCollector collector )
- throws DependencyTreeBuilderException;
-
- /**
- * Builds a tree of dependencies for the specified Maven project.
- *
- * @param project
- * the Maven project
- * @param repository
- * the artifact repository to resolve against
- * @param factory
- * the artifact factory to use
- * @param metadataSource
- * the artifact metadata source to use
- * @param filter
- * the artifact filter to use
- * @param collector
- * the artifact collector to use
- * @return the dependency tree root node of the specified Maven project
- * @throws DependencyTreeBuilderException
- * if the dependency tree cannot be resolved
- * @since 1.1
- */
- DependencyNode buildDependencyTree( MavenProject project, ArtifactRepository repository, ArtifactFactory factory,
- ArtifactMetadataSource metadataSource, ArtifactFilter filter, ArtifactCollector collector )
- throws DependencyTreeBuilderException;
-}
diff --git a/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreeBuilderException.java b/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreeBuilderException.java
deleted file mode 100644
index 8f9a0a8..0000000
--- a/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreeBuilderException.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package org.apache.maven.shared.dependency.tree;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Indicates that a Maven project's dependency tree cannot be resolved.
- *
- * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
- * @version $Id: DependencyTreeBuilderException.java 661727 2008-05-30 14:21:49Z bentmann $
- */
-public class DependencyTreeBuilderException extends Exception
-{
- // constants --------------------------------------------------------------
-
- /**
- * The serialisation unique ID.
- */
- private static final long serialVersionUID = -3525803081807951764L;
-
- // constructors -----------------------------------------------------------
-
- public DependencyTreeBuilderException( String message )
- {
- super( message );
- }
-
- public DependencyTreeBuilderException( String message, Throwable cause )
- {
- super( message, cause );
- }
-}
diff --git a/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreeInverseIterator.java b/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreeInverseIterator.java
deleted file mode 100644
index 1c9e764..0000000
--- a/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreeInverseIterator.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package org.apache.maven.shared.dependency.tree;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import java.util.Stack;
-
-/**
- * {@link Iterator} for {@link DependencyNode} implementing a traversal from leaves to root.
- *
- * TODO {@link #DependencyTreeInverseIterator(DependencyNode)} is costly,
- * a better implementation would move the cost to {@link #next()}
- *
- * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
- * @version $Id: DependencyTreeInverseIterator.java 661727 2008-05-30 14:21:49Z bentmann $
- */
-public class DependencyTreeInverseIterator
- implements Iterator
-{
- private Stack nodesToProcess = new Stack();
-
- public DependencyTreeInverseIterator( DependencyNode rootNode )
- {
- DependencyTreePreorderIterator it = new DependencyTreePreorderIterator( rootNode );
- while ( it.hasNext() )
- {
- nodesToProcess.push( it.next() );
- }
- }
-
- public boolean hasNext()
- {
- return !nodesToProcess.isEmpty();
- }
-
- public Object next()
- {
- if ( !hasNext() )
- {
- throw new NoSuchElementException();
- }
- return nodesToProcess.pop();
- }
-
- /**
- * @throws UnsupportedOperationException
- */
- public void remove()
- {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreePreorderIterator.java b/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreePreorderIterator.java
deleted file mode 100644
index df5277f..0000000
--- a/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreePreorderIterator.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package org.apache.maven.shared.dependency.tree;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-import java.util.Stack;
-
-/**
- * {@link Iterator} for {@link DependencyNode} implementing a preoder traversal.
- *
- * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
- * @version $Id: DependencyTreePreorderIterator.java 661727 2008-05-30 14:21:49Z bentmann $
- */
-public class DependencyTreePreorderIterator
- implements Iterator
-{
- private Stack nodesToProcess = new Stack();
-
- public DependencyTreePreorderIterator( DependencyNode rootNode )
- {
- nodesToProcess.push( rootNode );
- }
-
- public boolean hasNext()
- {
- return !nodesToProcess.isEmpty();
- }
-
- public Object next()
- {
- if ( !hasNext() )
- {
- throw new NoSuchElementException();
- }
- DependencyNode currentNode = (DependencyNode) nodesToProcess.pop();
- List children = currentNode.getChildren();
- if ( children != null )
- {
- for ( int i = children.size() - 1; i >= 0; i-- )
- {
- nodesToProcess.push( children.get( i ) );
- }
- }
- return currentNode;
- }
-
- /**
- * @throws UnsupportedOperationException
- */
- public void remove()
- {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreeResolutionListener.java b/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreeResolutionListener.java
index 492f382..b03b914 100644
--- a/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreeResolutionListener.java
+++ b/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreeResolutionListener.java
@@ -338,7 +338,7 @@
* Cache management information and apply in includeArtifact, since DefaultArtifactCollector mutates the
* artifact and then calls includeArtifact after manageArtifact.
*/
- managedVersions.put( replacement.getId(), artifact.getVersion() );
+ managedVersions.put( getRangeId( replacement ), artifact.getVersion() );
}
}
@@ -359,7 +359,7 @@
* Cache management information and apply in includeArtifact, since DefaultArtifactCollector mutates the
* artifact and then calls includeArtifact after manageArtifact.
*/
- managedScopes.put( replacement.getId(), artifact.getScope() );
+ managedScopes.put( getRangeId( replacement ), artifact.getScope() );
}
}
@@ -525,8 +525,8 @@
private void flushDependencyManagement( DependencyNode node )
{
Artifact artifact = node.getArtifact();
- String premanagedVersion = (String) managedVersions.get( artifact.getId() );
- String premanagedScope = (String) managedScopes.get( artifact.getId() );
+ String premanagedVersion = (String) managedVersions.get( getRangeId( artifact ) );
+ String premanagedScope = (String) managedScopes.get( getRangeId( artifact ) );
if ( premanagedVersion != null || premanagedScope != null )
{
@@ -544,4 +544,9 @@
premanagedScope = null;
}
}
+
+ private static String getRangeId( Artifact artifact )
+ {
+ return artifact.getDependencyConflictId() + ":" + artifact.getVersionRange();
+ }
}
diff --git a/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/filter/AncestorOrSelfDependencyNodeFilter.java b/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/filter/AncestorOrSelfDependencyNodeFilter.java
deleted file mode 100644
index 7f56896..0000000
--- a/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/filter/AncestorOrSelfDependencyNodeFilter.java
+++ /dev/null
@@ -1,110 +0,0 @@
-package org.apache.maven.shared.dependency.tree.filter;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.maven.shared.dependency.tree.DependencyNode;
-
-/**
- * A dependency node filter than only accepts nodes that are ancestors of, or equal to, a given list of nodes.
- *
- * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
- * @version $Id: AncestorOrSelfDependencyNodeFilter.java 661727 2008-05-30 14:21:49Z bentmann $
- * @since 1.1
- */
-public class AncestorOrSelfDependencyNodeFilter implements DependencyNodeFilter
-{
- // fields -----------------------------------------------------------------
-
- /**
- * The list of nodes that this filter accepts ancestors-or-self of.
- */
- private final List descendantNodes;
-
- // constructors -----------------------------------------------------------
-
- public AncestorOrSelfDependencyNodeFilter( DependencyNode descendantNode )
- {
- this( Collections.singletonList( descendantNode ) );
- }
-
- /**
- * Creates a dependency node filter that only accepts nodes that are ancestors of, or equal to, the specified list
- * of nodes.
- *
- * @param descendantNodes
- * the list of nodes to accept ancestors-or-self of
- */
- public AncestorOrSelfDependencyNodeFilter( List descendantNodes )
- {
- this.descendantNodes = descendantNodes;
- }
-
- // DependencyNodeFilter methods -------------------------------------------
-
- /**
- * {@inheritDoc}
- */
- public boolean accept( DependencyNode node )
- {
- boolean accept = false;
-
- for ( Iterator iterator = descendantNodes.iterator(); !accept && iterator.hasNext(); )
- {
- DependencyNode descendantNode = (DependencyNode) iterator.next();
-
- if ( isAncestorOrSelf( node, descendantNode ) )
- {
- accept = true;
- }
- }
-
- return accept;
- }
-
- // private methods --------------------------------------------------------
-
- /**
- * Gets whether the first dependency node is an ancestor-or-self of the second.
- *
- * @param ancestorNode
- * the ancestor-or-self dependency node
- * @param descendantNode
- * the dependency node to test
- * @return <code>true</code> if <code>ancestorNode</code> is an ancestor, or equal to,
- * <code>descendantNode</code>
- */
- private boolean isAncestorOrSelf( DependencyNode ancestorNode, DependencyNode descendantNode )
- {
- boolean ancestor = false;
-
- while ( !ancestor && descendantNode != null )
- {
- ancestor = ancestorNode.equals( descendantNode );
-
- descendantNode = descendantNode.getParent();
- }
-
- return ancestor;
- }
-}
diff --git a/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/filter/AndDependencyNodeFilter.java b/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/filter/AndDependencyNodeFilter.java
deleted file mode 100644
index b5f801c..0000000
--- a/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/filter/AndDependencyNodeFilter.java
+++ /dev/null
@@ -1,101 +0,0 @@
-package org.apache.maven.shared.dependency.tree.filter;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.maven.shared.dependency.tree.DependencyNode;
-
-/**
- * A dependency node filter that logically ANDs together a number of other dependency node filters.
- *
- * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
- * @version $Id: AndDependencyNodeFilter.java 661727 2008-05-30 14:21:49Z bentmann $
- * @since 1.1
- */
-public class AndDependencyNodeFilter implements DependencyNodeFilter
-{
- // fields -----------------------------------------------------------------
-
- /**
- * The dependency node filters that this filter ANDs together.
- */
- private final List filters;
-
- // constructors -----------------------------------------------------------
-
- /**
- * Creates a dependency node filter that logically ANDs together the two specified dependency node filters.
- *
- * @param filter1
- * the first dependency node filter to logically AND together
- * @param filter2
- * the second dependency node filter to logically AND together
- */
- public AndDependencyNodeFilter( DependencyNodeFilter filter1, DependencyNodeFilter filter2 )
- {
- this( Arrays.asList( new DependencyNodeFilter[] { filter1, filter2 } ) );
- }
-
- /**
- * Creates a dependency node filter that logically ANDs together the specified dependency node filters.
- *
- * @param filters
- * the list of dependency node filters to logically AND together
- */
- public AndDependencyNodeFilter( List filters )
- {
- this.filters = Collections.unmodifiableList( filters );
- }
-
- // DependencyNodeFilter methods -------------------------------------------
-
- /**
- * {@inheritDoc}
- */
- public boolean accept( DependencyNode node )
- {
- boolean accept = true;
-
- for ( Iterator iterator = filters.iterator(); accept && iterator.hasNext(); )
- {
- DependencyNodeFilter filter = (DependencyNodeFilter) iterator.next();
-
- accept = filter.accept( node );
- }
-
- return accept;
- }
-
- // public methods ---------------------------------------------------------
-
- /**
- * Gets the list of dependency node filters that this filter ANDs together.
- *
- * @return the dependency node filters that this filter ANDs together
- */
- public List getDependencyNodeFilters()
- {
- return filters;
- }
-}
diff --git a/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/filter/ArtifactDependencyNodeFilter.java b/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/filter/ArtifactDependencyNodeFilter.java
deleted file mode 100644
index 9db6d4e..0000000
--- a/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/filter/ArtifactDependencyNodeFilter.java
+++ /dev/null
@@ -1,78 +0,0 @@
-package org.apache.maven.shared.dependency.tree.filter;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
-import org.apache.maven.shared.dependency.tree.DependencyNode;
-
-/**
- * A dependency node filter that delegates to an artifact filter.
- *
- * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
- * @version $Id: ArtifactDependencyNodeFilter.java 661727 2008-05-30 14:21:49Z bentmann $
- * @since 1.1
- */
-public class ArtifactDependencyNodeFilter implements DependencyNodeFilter
-{
- // fields -----------------------------------------------------------------
-
- /**
- * The artifact filter this dependency node filter delegates to.
- */
- private final ArtifactFilter filter;
-
- // constructors -----------------------------------------------------------
-
- /**
- * Creates a dependency node filter that delegates to the specified artifact filter.
- *
- * @param filter
- * the artifact filter to delegate to
- */
- public ArtifactDependencyNodeFilter( ArtifactFilter filter )
- {
- this.filter = filter;
- }
-
- // DependencyNodeFilter methods -------------------------------------------
-
- /**
- * {@inheritDoc}
- */
- public boolean accept( DependencyNode node )
- {
- Artifact artifact = node.getArtifact();
-
- return filter.include( artifact );
- }
-
- // public methods ---------------------------------------------------------
-
- /**
- * Gets the artifact filter this dependency node filter delegates to.
- *
- * @return the artifact filter this dependency node filter delegates to
- */
- public ArtifactFilter getArtifactFilter()
- {
- return filter;
- }
-}
diff --git a/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/filter/DependencyNodeFilter.java b/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/filter/DependencyNodeFilter.java
deleted file mode 100644
index 221769d..0000000
--- a/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/filter/DependencyNodeFilter.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package org.apache.maven.shared.dependency.tree.filter;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.shared.dependency.tree.DependencyNode;
-
-/**
- * Defines a filter for dependency nodes.
- *
- * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
- * @version $Id: DependencyNodeFilter.java 661727 2008-05-30 14:21:49Z bentmann $
- * @since 1.1
- */
-public interface DependencyNodeFilter
-{
- /**
- * Gets whether this filter accepts the specified dependency node.
- *
- * @param node
- * the dependency node to check
- * @return <code>true</code> if this filter accepts the specified dependency node
- */
- boolean accept( DependencyNode node );
-}
diff --git a/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/filter/StateDependencyNodeFilter.java b/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/filter/StateDependencyNodeFilter.java
deleted file mode 100644
index 116cd80..0000000
--- a/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/filter/StateDependencyNodeFilter.java
+++ /dev/null
@@ -1,90 +0,0 @@
-package org.apache.maven.shared.dependency.tree.filter;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.shared.dependency.tree.DependencyNode;
-
-/**
- * A dependency node filter that accepts nodes depending on their state.
- *
- * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
- * @version $Id: StateDependencyNodeFilter.java 661727 2008-05-30 14:21:49Z bentmann $
- * @since 1.1
- */
-public class StateDependencyNodeFilter implements DependencyNodeFilter
-{
- // constants --------------------------------------------------------------
-
- /**
- * A dependency node filter that only accepts included nodes.
- */
- public static final StateDependencyNodeFilter INCLUDED = new StateDependencyNodeFilter( DependencyNode.INCLUDED );
-
- // fields -----------------------------------------------------------------
-
- /**
- * The state of dependency nodes to accept.
- *
- * @see DependencyNode
- */
- private final int state;
-
- // constructors -----------------------------------------------------------
-
- /**
- * Creates a dependency node filter that only accepts dependency nodes of the specified state.
- *
- * @param state
- * the state of dependency nodes to accept
- * @throws IllegalArgumentException
- * if the specified state is invalid
- */
- public StateDependencyNodeFilter( int state )
- {
- if ( state < DependencyNode.INCLUDED || state > DependencyNode.OMITTED_FOR_CYCLE )
- {
- throw new IllegalArgumentException( "Unknown state: " + state );
- }
-
- this.state = state;
- }
-
- // DependencyNodeFilter methods -------------------------------------------
-
- /**
- * {@inheritDoc}
- */
- public boolean accept( DependencyNode node )
- {
- return node.getState() == state;
- }
-
- // public methods ---------------------------------------------------------
-
- /**
- * Gets the dependency node state that this filter accepts.
- *
- * @return the dependency node state that this filter accepts
- */
- public int getState()
- {
- return state;
- }
-}
diff --git a/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/traversal/BuildingDependencyNodeVisitor.java b/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/traversal/BuildingDependencyNodeVisitor.java
deleted file mode 100644
index 2be5777..0000000
--- a/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/traversal/BuildingDependencyNodeVisitor.java
+++ /dev/null
@@ -1,143 +0,0 @@
-package org.apache.maven.shared.dependency.tree.traversal;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.Stack;
-
-import org.apache.maven.shared.dependency.tree.DependencyNode;
-
-/**
- * A dependency node visitor that clones visited nodes into a new dependency tree. This can be used in conjunction with
- * a dependency node filter to construct subtrees.
- *
- * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
- * @version $Id: BuildingDependencyNodeVisitor.java 661727 2008-05-30 14:21:49Z bentmann $
- * @since 1.1
- */
-public class BuildingDependencyNodeVisitor implements DependencyNodeVisitor
-{
- // fields -----------------------------------------------------------------
-
- /**
- * The dependency node visitor to apply on the resultant dependency tree, or <code>null</code> for none.
- */
- private final DependencyNodeVisitor visitor;
-
- /**
- * The resultant tree parent nodes for the currently visited node.
- */
- private final Stack parentNodes;
-
- /**
- * The root node of the resultant tree.
- */
- private DependencyNode rootNode;
-
- // constructors -----------------------------------------------------------
-
- /**
- * Creates a dependency node visitor that clones visited nodes into a new dependency tree.
- */
- public BuildingDependencyNodeVisitor()
- {
- this( null );
- }
-
- /**
- * Creates a dependency node visitor that clones visited nodes into a new dependency tree, and then applies the
- * specified dependency node visitor on the resultant dependency tree.
- *
- * @param visitor
- * the dependency node visitor to apply on the resultant dependency tree, or <code>null</code> for none
- */
- public BuildingDependencyNodeVisitor( DependencyNodeVisitor visitor )
- {
- this.visitor = visitor;
-
- parentNodes = new Stack();
- }
-
- // DependencyNodeVisitor methods ------------------------------------------
-
- /**
- * {@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 = (DependencyNode) parentNodes.peek();
- parentNode.addChild( newNode );
- }
-
- parentNodes.push( newNode );
-
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean endVisit( DependencyNode node )
- {
- parentNodes.pop();
-
- // apply the visitor to the resultant tree on the last visit
- if ( parentNodes.empty() && visitor != null )
- {
- rootNode.accept( visitor );
- }
-
- return true;
- }
-
- // public methods ---------------------------------------------------------
-
- /**
- * Gets the dependency node visitor that this visitor applies on the resultant dependency tree.
- *
- * @return the dependency node visitor, or <code>null</code> for none
- */
- public DependencyNodeVisitor getDependencyNodeVisitor()
- {
- return visitor;
- }
-
- /**
- * Gets the root node of the resultant dependency tree constructed by this visitor.
- *
- * @return the root node, or <code>null</code> if the source tree has not yet been visited
- */
- public DependencyNode getDependencyTree()
- {
- return rootNode;
- }
-}
diff --git a/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/traversal/CollectingDependencyNodeVisitor.java b/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/traversal/CollectingDependencyNodeVisitor.java
deleted file mode 100644
index b813267..0000000
--- a/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/traversal/CollectingDependencyNodeVisitor.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package org.apache.maven.shared.dependency.tree.traversal;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.maven.shared.dependency.tree.DependencyNode;
-
-/**
- * A dependency node visitor that collects visited nodes for further processing.
- *
- * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
- * @version $Id: CollectingDependencyNodeVisitor.java 661727 2008-05-30 14:21:49Z bentmann $
- * @since 1.1
- */
-public class CollectingDependencyNodeVisitor implements DependencyNodeVisitor
-{
- // fields -----------------------------------------------------------------
-
- /**
- * The collected list of nodes.
- */
- private final List nodes;
-
- // constructors -----------------------------------------------------------
-
- /**
- * Creates a dependency node visitor that collects visited nodes for further processing.
- */
- public CollectingDependencyNodeVisitor()
- {
- nodes = new ArrayList();
- }
-
- // DependencyNodeVisitor methods ------------------------------------------
-
- /**
- * {@inheritDoc}
- */
- public boolean visit( DependencyNode node )
- {
- // collect node
- nodes.add( node );
-
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean endVisit( DependencyNode node )
- {
- return true;
- }
-
- // public methods ---------------------------------------------------------
-
- /**
- * Gets the list of collected dependency nodes.
- *
- * @return the list of collected dependency nodes
- */
- public List getNodes()
- {
- return Collections.unmodifiableList( nodes );
- }
-}
diff --git a/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/traversal/DependencyNodeVisitor.java b/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/traversal/DependencyNodeVisitor.java
deleted file mode 100644
index 011c9cb..0000000
--- a/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/traversal/DependencyNodeVisitor.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package org.apache.maven.shared.dependency.tree.traversal;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.shared.dependency.tree.DependencyNode;
-
-/**
- * Defines a hierarchical visitor for processing dependency node trees.
- *
- * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
- * @version $Id: DependencyNodeVisitor.java 661727 2008-05-30 14:21:49Z bentmann $
- * @since 1.1
- */
-public interface DependencyNodeVisitor
-{
- /**
- * Starts the visit to the specified dependency node.
- *
- * @param node
- * the dependency node to visit
- * @return <code>true</code> to visit the specified dependency node's children, <code>false</code> to skip the
- * specified dependency node's children and proceed to its next sibling
- */
- boolean visit( DependencyNode node );
-
- /**
- * Ends the visit to to the specified dependency node.
- *
- * @param node
- * the dependency node to visit
- * @return <code>true</code> to visit the specified dependency node's next sibling, <code>false</code> to skip
- * the specified dependency node's next siblings and proceed to its parent
- */
- boolean endVisit( DependencyNode node );
-}
diff --git a/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/traversal/FilteringDependencyNodeVisitor.java b/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/traversal/FilteringDependencyNodeVisitor.java
deleted file mode 100644
index 86cf6e8..0000000
--- a/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/traversal/FilteringDependencyNodeVisitor.java
+++ /dev/null
@@ -1,124 +0,0 @@
-package org.apache.maven.shared.dependency.tree.traversal;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.shared.dependency.tree.DependencyNode;
-import org.apache.maven.shared.dependency.tree.filter.DependencyNodeFilter;
-
-/**
- * A dependency node visitor that filters nodes and delegates to another visitor.
- *
- * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
- * @version $Id: FilteringDependencyNodeVisitor.java 661727 2008-05-30 14:21:49Z bentmann $
- * @since 1.1
- */
-public class FilteringDependencyNodeVisitor implements DependencyNodeVisitor
-{
- // fields -----------------------------------------------------------------
-
- /**
- * The dependency node visitor to delegate to.
- */
- private final DependencyNodeVisitor visitor;
-
- /**
- * The dependency node filter to apply before delegation.
- */
- private final DependencyNodeFilter filter;
-
- // constructors -----------------------------------------------------------
-
- /**
- * Creates a dependency node visitor that delegates nodes that are accepted by the specified filter to the specified
- * visitor.
- *
- * @param visitor
- * the dependency node visitor to delegate to
- * @param filter
- * the dependency node filter to apply before delegation
- */
- public FilteringDependencyNodeVisitor( DependencyNodeVisitor visitor, DependencyNodeFilter filter )
- {
- this.visitor = visitor;
- this.filter = filter;
- }
-
- // DependencyNodeVisitor methods ------------------------------------------
-
- /**
- * {@inheritDoc}
- */
- public boolean visit( DependencyNode node )
- {
- boolean visit;
-
- if ( filter.accept( node ) )
- {
- visit = visitor.visit( node );
- }
- else
- {
- visit = true;
- }
-
- return visit;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean endVisit( DependencyNode node )
- {
- boolean visit;
-
- if ( filter.accept( node ) )
- {
- visit = visitor.endVisit( node );
- }
- else
- {
- visit = true;
- }
-
- return visit;
- }
-
- // public methods ---------------------------------------------------------
-
- /**
- * Gets the dependency node visitor that this visitor delegates to.
- *
- * @return the dependency node visitor
- */
- public DependencyNodeVisitor getDependencyNodeVisitor()
- {
- return visitor;
- }
-
- /**
- * Gets the dependency node filter that this visitor applies before delegation.
- *
- * @return the dependency node filter
- */
- public DependencyNodeFilter getDependencyNodeFilter()
- {
- return filter;
- }
-}
diff --git a/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/traversal/SerializingDependencyNodeVisitor.java b/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/traversal/SerializingDependencyNodeVisitor.java
deleted file mode 100644
index 14422a4..0000000
--- a/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/traversal/SerializingDependencyNodeVisitor.java
+++ /dev/null
@@ -1,242 +0,0 @@
-package org.apache.maven.shared.dependency.tree.traversal;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.PrintWriter;
-import java.io.Writer;
-import java.util.List;
-
-import org.apache.maven.shared.dependency.tree.DependencyNode;
-
-/**
- * A dependency node visitor that serializes visited nodes to a writer.
- *
- * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
- * @version $Id: SerializingDependencyNodeVisitor.java 661727 2008-05-30 14:21:49Z bentmann $
- * @since 1.1
- */
-public class SerializingDependencyNodeVisitor implements DependencyNodeVisitor
-{
- // classes ----------------------------------------------------------------
-
- /**
- * Provides tokens to use when serializing the dependency tree.
- */
- public static class TreeTokens
- {
- private final String nodeIndent;
-
- private final String lastNodeIndent;
-
- private final String fillIndent;
-
- private final String lastFillIndent;
-
- public TreeTokens( String nodeIndent, String lastNodeIndent, String fillIndent, String lastFillIndent )
- {
- this.nodeIndent = nodeIndent;
- this.lastNodeIndent = lastNodeIndent;
- this.fillIndent = fillIndent;
- this.lastFillIndent = lastFillIndent;
- }
-
- public String getNodeIndent( boolean last )
- {
- return last ? lastNodeIndent : nodeIndent;
- }
-
- public String getFillIndent( boolean last )
- {
- return last ? lastFillIndent : fillIndent;
- }
- }
-
- // constants --------------------------------------------------------------
-
- /**
- * Whitespace tokens to use when outputing the dependency tree.
- */
- public static final TreeTokens WHITESPACE_TOKENS = new TreeTokens( " ", " ", " ", " " );
-
- /**
- * The standard ASCII tokens to use when outputing the dependency tree.
- */
- public static final TreeTokens STANDARD_TOKENS = new TreeTokens( "+- ", "\\- ", "| ", " " );
-
- /**
- * The extended ASCII tokens to use when outputing the dependency tree.
- */
- public static final TreeTokens EXTENDED_TOKENS =
- new TreeTokens( "\u00c3\u00c4 ", "\u00c0\u00c4 ", "\u00b3 ", " " );
-
- // fields -----------------------------------------------------------------
-
- /**
- * The writer to serialize to.
- */
- private final PrintWriter writer;
-
- /**
- * The tokens to use when serializing the dependency tree.
- */
- private final TreeTokens tokens;
-
- /**
- * The depth of the currently visited dependency node.
- */
- private int depth;
-
- // constructors -----------------------------------------------------------
-
- /**
- * Creates a dependency node visitor that serializes visited nodes to the specified writer using whitespace tokens.
- *
- * @param writer
- * the writer to serialize to
- */
- public SerializingDependencyNodeVisitor( Writer writer )
- {
- this( writer, WHITESPACE_TOKENS );
- }
-
- /**
- * Creates a dependency node visitor that serializes visited nodes to the specified writer using the specified
- * tokens.
- *
- * @param writer
- * the writer to serialize to
- * @param tokens
- * the tokens to use when serializing the dependency tree
- */
- public SerializingDependencyNodeVisitor( Writer writer, TreeTokens tokens )
- {
- if ( writer instanceof PrintWriter )
- {
- this.writer = (PrintWriter) writer;
- }
- else
- {
- this.writer = new PrintWriter( writer, true );
- }
-
- this.tokens = tokens;
-
- depth = 0;
- }
-
- // DependencyNodeVisitor methods ------------------------------------------
-
- /**
- * {@inheritDoc}
- */
- public boolean visit( DependencyNode node )
- {
- indent( node );
-
- writer.println( node.toNodeString() );
-
- depth++;
-
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean endVisit( DependencyNode node )
- {
- depth--;
-
- return true;
- }
-
- // private methods --------------------------------------------------------
-
- /**
- * Writes the necessary tokens to indent the specified dependency node to this visitor's writer.
- *
- * @param node
- * the dependency node to indent
- */
- private void indent( DependencyNode node )
- {
- for ( int i = 1; i < depth; i++ )
- {
- writer.write( tokens.getFillIndent( isLast( node, i ) ) );
- }
-
- if ( depth > 0 )
- {
- writer.write( tokens.getNodeIndent( isLast( node ) ) );
- }
- }
-
- /**
- * 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 siblings = parent.getChildren();
-
- last = ( siblings.indexOf( node ) == siblings.size() - 1 );
- }
-
- return last;
- }
-
- /**
- * Gets whether the specified dependency node ancestor is the last of its siblings.
- *
- * @param node
- * the dependency node whose ancestor to check
- * @param ancestorDepth
- * the depth of the ancestor of the specified dependency node to check
- * @return <code>true</code> if the specified dependency node ancestor is the last of its siblings
- */
- private boolean isLast( DependencyNode node, int ancestorDepth )
- {
- // TODO: remove node argument and calculate from visitor calls only
-
- int distance = depth - ancestorDepth;
-
- while ( distance-- > 0 )
- {
- node = node.getParent();
- }
-
- return isLast( node );
- }
-}