Source formatting
git-svn-id: https://svn.apache.org/repos/asf/maven/shared/trunk@1595642 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/maven/shared/dependency/graph/DependencyGraphBuilder.java b/src/main/java/org/apache/maven/shared/dependency/graph/DependencyGraphBuilder.java
index 9ab2c8c..002b3d8 100644
--- a/src/main/java/org/apache/maven/shared/dependency/graph/DependencyGraphBuilder.java
+++ b/src/main/java/org/apache/maven/shared/dependency/graph/DependencyGraphBuilder.java
@@ -33,10 +33,9 @@
public interface DependencyGraphBuilder
{
/**
- * Build the dependency graph from the repository.
- *
- * This is the same as {@link #buildDependencyGraph(org.apache.maven.project.MavenProject,
- * org.apache.maven.artifact.resolver.filter.ArtifactFilter, java.util.Map)} with an empty reactorProjects Map.
+ * Build the dependency graph from the repository. This is the same as
+ * {@link #buildDependencyGraph(org.apache.maven.project.MavenProject, org.apache.maven.artifact.resolver.filter.ArtifactFilter, java.util.Map)}
+ * with an empty reactorProjects Map.
*
* @param project the project
* @param filter artifact filter (can be <code>null</code>
@@ -51,12 +50,12 @@
*
* @param project the project
* @param filter artifact filter (can be <code>null</code>
- * @param reactorProjects Map of those projects contained in the reactor.
- * Key is made up of groupId-artifactId-version.
+ * @param reactorProjects Map of those projects contained in the reactor. Key is made up of
+ * groupId-artifactId-version.
* @return the dependency graph
* @throws DependencyGraphBuilderException
*/
- DependencyNode buildDependencyGraph(
- MavenProject project, ArtifactFilter filter, Map<String, MavenProject> reactorProjects )
- throws DependencyGraphBuilderException;
+ DependencyNode buildDependencyGraph( MavenProject project, ArtifactFilter filter,
+ Map<String, MavenProject> reactorProjects )
+ throws DependencyGraphBuilderException;
}
diff --git a/src/main/java/org/apache/maven/shared/dependency/graph/DependencyNode.java b/src/main/java/org/apache/maven/shared/dependency/graph/DependencyNode.java
index f96371f..ccbea2b 100644
--- a/src/main/java/org/apache/maven/shared/dependency/graph/DependencyNode.java
+++ b/src/main/java/org/apache/maven/shared/dependency/graph/DependencyNode.java
@@ -25,9 +25,8 @@
import org.apache.maven.shared.dependency.graph.traversal.DependencyNodeVisitor;
/**
- * Represents an artifact node within a Maven project's dependency graph. Notice there is no support
- * for ommitted nodes at the moment, only dependencies kept in the resolved dependency list are
- * available.
+ * Represents an artifact node within a Maven project's dependency graph. Notice there is no support for ommitted nodes
+ * at the moment, only dependencies kept in the resolved dependency list are available.
*
* @author Hervé Boutemy
* @since 2.0
@@ -41,8 +40,7 @@
/**
* Applies the specified dependency node visitor to this dependency node and its children.
*
- * @param visitor
- * the dependency node visitor to use
+ * @param visitor the dependency node visitor to use
* @return the visitor result of ending the visit to this node
* @since 1.1
*/
diff --git a/src/main/java/org/apache/maven/shared/dependency/graph/ProjectReferenceKeyGenerator.java b/src/main/java/org/apache/maven/shared/dependency/graph/ProjectReferenceKeyGenerator.java
index 55f9127..772dfdb 100644
--- a/src/main/java/org/apache/maven/shared/dependency/graph/ProjectReferenceKeyGenerator.java
+++ b/src/main/java/org/apache/maven/shared/dependency/graph/ProjectReferenceKeyGenerator.java
@@ -18,14 +18,14 @@
* specific language governing permissions and limitations
* under the License.
*/
-
+
import org.apache.maven.project.MavenProject;
/**
- * Generates the key used by {@link org.apache.maven.project.MavenProject#getProjectReferences()}
- * , {@link org.apache.maven.execution.MavenSession#getProjectMap()} and the Map passed into
- * {@link org.apache.maven.shared.dependency.graph.DependencyGraphBuilder#buildDependencyGraph
- * (org.apache.maven.project.MavenProject, org.apache.maven.artifact.resolver.filter.ArtifactFilter, java.util.Map)}.
+ * Generates the key used by {@link org.apache.maven.project.MavenProject#getProjectReferences()} ,
+ * {@link org.apache.maven.execution.MavenSession#getProjectMap()} and the Map passed into
+ * {@link org.apache.maven.shared.dependency.graph.DependencyGraphBuilder#buildDependencyGraph (org.apache.maven.project.MavenProject, org.apache.maven.artifact.resolver.filter.ArtifactFilter, java.util.Map)}
+ * .
*/
public final class ProjectReferenceKeyGenerator
{
diff --git a/src/main/java/org/apache/maven/shared/dependency/graph/filter/AncestorOrSelfDependencyNodeFilter.java b/src/main/java/org/apache/maven/shared/dependency/graph/filter/AncestorOrSelfDependencyNodeFilter.java
index fb2f631..d902ca3 100644
--- a/src/main/java/org/apache/maven/shared/dependency/graph/filter/AncestorOrSelfDependencyNodeFilter.java
+++ b/src/main/java/org/apache/maven/shared/dependency/graph/filter/AncestorOrSelfDependencyNodeFilter.java
@@ -52,8 +52,7 @@
* 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
+ * @param descendantNodes the list of nodes to accept ancestors-or-self of
*/
public AncestorOrSelfDependencyNodeFilter( List<DependencyNode> descendantNodes )
{
@@ -83,12 +82,9 @@
/**
* 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>
+ * @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 )
{
diff --git a/src/main/java/org/apache/maven/shared/dependency/graph/filter/AndDependencyNodeFilter.java b/src/main/java/org/apache/maven/shared/dependency/graph/filter/AndDependencyNodeFilter.java
index d50cef1..4c8008a 100644
--- a/src/main/java/org/apache/maven/shared/dependency/graph/filter/AndDependencyNodeFilter.java
+++ b/src/main/java/org/apache/maven/shared/dependency/graph/filter/AndDependencyNodeFilter.java
@@ -47,10 +47,8 @@
/**
* 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
+ * @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 )
{
@@ -60,8 +58,7 @@
/**
* 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
+ * @param filters the list of dependency node filters to logically AND together
*/
public AndDependencyNodeFilter( List<DependencyNodeFilter> filters )
{
diff --git a/src/main/java/org/apache/maven/shared/dependency/graph/filter/ArtifactDependencyNodeFilter.java b/src/main/java/org/apache/maven/shared/dependency/graph/filter/ArtifactDependencyNodeFilter.java
index fbe18c7..a5488df 100644
--- a/src/main/java/org/apache/maven/shared/dependency/graph/filter/ArtifactDependencyNodeFilter.java
+++ b/src/main/java/org/apache/maven/shared/dependency/graph/filter/ArtifactDependencyNodeFilter.java
@@ -45,8 +45,7 @@
/**
* Creates a dependency node filter that delegates to the specified artifact filter.
*
- * @param filter
- * the artifact filter to delegate to
+ * @param filter the artifact filter to delegate to
*/
public ArtifactDependencyNodeFilter( ArtifactFilter filter )
{
diff --git a/src/main/java/org/apache/maven/shared/dependency/graph/filter/DependencyNodeFilter.java b/src/main/java/org/apache/maven/shared/dependency/graph/filter/DependencyNodeFilter.java
index 7b0f481..0d508d0 100644
--- a/src/main/java/org/apache/maven/shared/dependency/graph/filter/DependencyNodeFilter.java
+++ b/src/main/java/org/apache/maven/shared/dependency/graph/filter/DependencyNodeFilter.java
@@ -33,8 +33,7 @@
/**
* Gets whether this filter accepts the specified dependency node.
*
- * @param node
- * the dependency node to check
+ * @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/src/main/java/org/apache/maven/shared/dependency/graph/internal/DefaultDependencyGraphBuilder.java b/src/main/java/org/apache/maven/shared/dependency/graph/internal/DefaultDependencyGraphBuilder.java
index 508b18b..95b5763 100644
--- a/src/main/java/org/apache/maven/shared/dependency/graph/internal/DefaultDependencyGraphBuilder.java
+++ b/src/main/java/org/apache/maven/shared/dependency/graph/internal/DefaultDependencyGraphBuilder.java
@@ -37,8 +37,8 @@
import java.util.Map;
/**
- * Default dependency graph builder that detects current Maven version to delegate to either
- * Maven 2 or Maven 3 specific code.
+ * Default dependency graph builder that detects current Maven version to delegate to either Maven 2 or Maven 3 specific
+ * code.
*
* @see Maven2DependencyGraphBuilder
* @see Maven3DependencyGraphBuilder
@@ -58,18 +58,18 @@
return buildDependencyGraph( project, filter, Collections.EMPTY_MAP );
}
- public DependencyNode buildDependencyGraph(
- MavenProject project, ArtifactFilter filter, Map<String, MavenProject> reactorProjects )
- throws DependencyGraphBuilderException
+ public DependencyNode buildDependencyGraph( MavenProject project, ArtifactFilter filter,
+ Map<String, MavenProject> reactorProjects )
+ throws DependencyGraphBuilderException
{
try
{
String hint = isMaven31() ? "maven31" : isMaven2x() ? "maven2" : "maven3";
DependencyGraphBuilder effectiveGraphBuilder =
- (DependencyGraphBuilder) container.lookup( DependencyGraphBuilder.class.getCanonicalName(), hint );
- getLogger().debug( "building " + hint + " dependency graph for " + project.getId()
- + " with " + effectiveGraphBuilder.getClass() );
+ (DependencyGraphBuilder) container.lookup( DependencyGraphBuilder.class.getCanonicalName(), hint );
+ getLogger().debug( "building " + hint + " dependency graph for " + project.getId() + " with "
+ + effectiveGraphBuilder.getClass() );
return effectiveGraphBuilder.buildDependencyGraph( project, filter, reactorProjects );
}
@@ -95,7 +95,7 @@
return canFindCoreClass( "org.eclipse.aether.artifact.Artifact" ); // Maven 3.1 specific
}
- private static boolean canFindCoreClass( String className)
+ private static boolean canFindCoreClass( String className )
{
try
{
diff --git a/src/main/java/org/apache/maven/shared/dependency/graph/internal/DefaultDependencyNode.java b/src/main/java/org/apache/maven/shared/dependency/graph/internal/DefaultDependencyNode.java
index e5a89d6..2a8ef57 100644
--- a/src/main/java/org/apache/maven/shared/dependency/graph/internal/DefaultDependencyNode.java
+++ b/src/main/java/org/apache/maven/shared/dependency/graph/internal/DefaultDependencyNode.java
@@ -53,8 +53,7 @@
/**
* Applies the specified dependency node visitor to this dependency node and its children.
*
- * @param visitor
- * the dependency node visitor to use
+ * @param visitor the dependency node visitor to use
* @return the visitor result of ending the visit to this node
* @since 1.1
*/
@@ -114,77 +113,77 @@
StringBuffer buffer = new StringBuffer();
buffer.append( artifact );
-
+
ItemAppender appender = new ItemAppender( buffer, " (", "; ", ")" );
if ( getPremanagedVersion() != null )
{
appender.append( "version managed from ", getPremanagedVersion() );
}
-
+
if ( getPremanagedScope() != null )
{
appender.append( "scope managed from ", getPremanagedScope() );
}
-
+
if ( getVersionConstraint() != null )
{
appender.append( "version selected from constraint ", getVersionConstraint() );
}
-
+
appender.flush();
return buffer.toString();
}
/**
- * Utility class to concatenate a number of parameters with separator tokens.
+ * 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 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;
}
}
diff --git a/src/main/java/org/apache/maven/shared/dependency/graph/internal/Invoker.java b/src/main/java/org/apache/maven/shared/dependency/graph/internal/Invoker.java
index e4169d0..85fc968 100644
--- a/src/main/java/org/apache/maven/shared/dependency/graph/internal/Invoker.java
+++ b/src/main/java/org/apache/maven/shared/dependency/graph/internal/Invoker.java
@@ -18,7 +18,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-
+
import org.apache.maven.shared.dependency.graph.DependencyGraphBuilderException;
import java.lang.reflect.InvocationTargetException;
@@ -29,37 +29,43 @@
final class Invoker
{
public Object invoke( Class objectClazz, Object object, String method )
- throws DependencyGraphBuilderException
+ throws DependencyGraphBuilderException
{
try
{
return objectClazz.getMethod( method ).invoke( object );
- } catch ( IllegalAccessException e )
+ }
+ catch ( IllegalAccessException e )
{
throw new DependencyGraphBuilderException( e.getMessage(), e );
- } catch ( InvocationTargetException e )
+ }
+ catch ( InvocationTargetException e )
{
throw new DependencyGraphBuilderException( e.getMessage(), e );
- } catch ( NoSuchMethodException e )
+ }
+ catch ( NoSuchMethodException e )
{
throw new DependencyGraphBuilderException( e.getMessage(), e );
}
}
public Object invoke( Object object, String method, Class<?> clazz, Object arg )
- throws DependencyGraphBuilderException
+ throws DependencyGraphBuilderException
{
try
{
final Class objectClazz = object.getClass();
return objectClazz.getMethod( method, clazz ).invoke( object, arg );
- } catch ( IllegalAccessException e )
+ }
+ catch ( IllegalAccessException e )
{
throw new DependencyGraphBuilderException( e.getMessage(), e );
- } catch ( InvocationTargetException e )
+ }
+ catch ( InvocationTargetException e )
{
throw new DependencyGraphBuilderException( e.getMessage(), e );
- } catch ( NoSuchMethodException e )
+ }
+ catch ( NoSuchMethodException e )
{
throw new DependencyGraphBuilderException( e.getMessage(), e );
}
diff --git a/src/main/java/org/apache/maven/shared/dependency/graph/internal/Maven2DependencyGraphBuilder.java b/src/main/java/org/apache/maven/shared/dependency/graph/internal/Maven2DependencyGraphBuilder.java
index 6a6e49c..df37ab0 100644
--- a/src/main/java/org/apache/maven/shared/dependency/graph/internal/Maven2DependencyGraphBuilder.java
+++ b/src/main/java/org/apache/maven/shared/dependency/graph/internal/Maven2DependencyGraphBuilder.java
@@ -63,9 +63,9 @@
}
}
- public DependencyNode buildDependencyGraph(
- MavenProject project, ArtifactFilter filter, Map<String, MavenProject> reactorProjects )
- throws DependencyGraphBuilderException
+ public DependencyNode buildDependencyGraph( MavenProject project, ArtifactFilter filter,
+ Map<String, MavenProject> reactorProjects )
+ throws DependencyGraphBuilderException
{
getLogger().warn( "Reactor projects ignored - reactor dependencies cannot be resolved in Maven2" );
return buildDependencyGraph( project, filter );
diff --git a/src/main/java/org/apache/maven/shared/dependency/graph/internal/Maven31DependencyGraphBuilder.java b/src/main/java/org/apache/maven/shared/dependency/graph/internal/Maven31DependencyGraphBuilder.java
index 80f2782..4f8e7da 100644
--- a/src/main/java/org/apache/maven/shared/dependency/graph/internal/Maven31DependencyGraphBuilder.java
+++ b/src/main/java/org/apache/maven/shared/dependency/graph/internal/Maven31DependencyGraphBuilder.java
@@ -66,6 +66,7 @@
private ArtifactFactory factory;
private final Invoker invoker = new Invoker();
+
private final ProjectReferenceKeyGenerator keyGenerator = new ProjectReferenceKeyGenerator();
public DependencyNode buildDependencyGraph( MavenProject project, ArtifactFilter filter )
@@ -74,23 +75,23 @@
return buildDependencyGraph( project, filter, Collections.EMPTY_MAP );
}
- public DependencyNode buildDependencyGraph(
- MavenProject project, ArtifactFilter filter, Map<String, MavenProject> reactorProjects )
- throws DependencyGraphBuilderException
+ public DependencyNode buildDependencyGraph( MavenProject project, ArtifactFilter filter,
+ Map<String, MavenProject> reactorProjects )
+ throws DependencyGraphBuilderException
{
ProjectBuildingRequest projectBuildingRequest =
- (ProjectBuildingRequest) invoker.invoke( project.getClass(), project, "getProjectBuildingRequest" );
+ (ProjectBuildingRequest) invoker.invoke( project.getClass(), project, "getProjectBuildingRequest" );
RepositorySystemSession session =
- (RepositorySystemSession) invoker.invoke( ProjectBuildingRequest.class, projectBuildingRequest,
- "getRepositorySession" );
+ (RepositorySystemSession) invoker.invoke( ProjectBuildingRequest.class, projectBuildingRequest,
+ "getRepositorySession" );
- /*if ( Boolean.TRUE != ( (Boolean) session.getConfigProperties().get( DependencyManagerUtils.NODE_DATA_PREMANAGED_VERSION ) ) )
- {
- DefaultRepositorySystemSession newSession = new DefaultRepositorySystemSession( session );
- newSession.setConfigProperty( DependencyManagerUtils.NODE_DATA_PREMANAGED_VERSION, true );
- session = newSession;
- }*/
+ /*
+ * if ( Boolean.TRUE != ( (Boolean) session.getConfigProperties().get(
+ * DependencyManagerUtils.NODE_DATA_PREMANAGED_VERSION ) ) ) { DefaultRepositorySystemSession newSession = new
+ * DefaultRepositorySystemSession( session ); newSession.setConfigProperty(
+ * DependencyManagerUtils.NODE_DATA_PREMANAGED_VERSION, true ); session = newSession; }
+ */
final DependencyResolutionRequest request = new DefaultDependencyResolutionRequest();
request.setMavenProject( project );
@@ -98,15 +99,15 @@
final DependencyResolutionResult result = resolveDependencies( request, reactorProjects );
org.eclipse.aether.graph.DependencyNode graph =
- ( org.eclipse.aether.graph.DependencyNode ) invoker.invoke( DependencyResolutionResult.class, result,
- "getDependencyGraph" );
+ (org.eclipse.aether.graph.DependencyNode) invoker.invoke( DependencyResolutionResult.class, result,
+ "getDependencyGraph" );
return buildDependencyNode( null, graph, project.getArtifact(), filter );
}
- private DependencyResolutionResult resolveDependencies(DependencyResolutionRequest request,
- Map<String, MavenProject> reactorProjects)
- throws DependencyGraphBuilderException
+ private DependencyResolutionResult resolveDependencies( DependencyResolutionRequest request,
+ Map<String, MavenProject> reactorProjects )
+ throws DependencyGraphBuilderException
{
try
{
@@ -126,13 +127,15 @@
// NB There doesn't seem to be any way to apply this to Maven2DependencyGraphBuilder as there is no
// concept of partial resolution like there is is 3 and 3.1
final DependencyResolutionResult result = e.getResult();
- final List<Dependency> reactorDeps = getReactorDependencies( reactorProjects, result.getUnresolvedDependencies() );
+ final List<Dependency> reactorDeps =
+ getReactorDependencies( reactorProjects, result.getUnresolvedDependencies() );
invoker.invoke( result.getUnresolvedDependencies(), "removeAll", Collection.class, reactorDeps );
invoker.invoke( result.getResolvedDependencies(), "addAll", Collection.class, reactorDeps );
- if ( !result.getUnresolvedDependencies().isEmpty() ) {
+ if ( !result.getUnresolvedDependencies().isEmpty() )
+ {
throw new DependencyGraphBuilderException( "Could not resolve the following dependencies : "
- + result.getUnresolvedDependencies(), e );
+ + result.getUnresolvedDependencies(), e );
}
getLogger().debug( "Resolved dependencies after ignoring reactor dependencies : " + reactorDeps );
return result;
@@ -146,10 +149,11 @@
{
final Dependency dependency = (Dependency) untypedDependency;
final org.eclipse.aether.artifact.Artifact depArtifact = dependency.getArtifact();
- final String projectRefId = keyGenerator.getProjectReferenceKey(
- depArtifact.getGroupId(), depArtifact.getArtifactId(), depArtifact.getVersion()
- );
- if ( reactorProjects.containsKey( projectRefId ) ) {
+ final String projectRefId =
+ keyGenerator.getProjectReferenceKey( depArtifact.getGroupId(), depArtifact.getArtifactId(),
+ depArtifact.getVersion() );
+ if ( reactorProjects.containsKey( projectRefId ) )
+ {
reactorDeps.add( dependency );
}
}
@@ -169,8 +173,8 @@
private DependencyNode buildDependencyNode( DependencyNode parent, org.eclipse.aether.graph.DependencyNode node,
Artifact artifact, ArtifactFilter filter )
{
- String premanagedVersion = null; //DependencyManagerUtils.getPremanagedVersion( node );
- String premanagedScope = null; //DependencyManagerUtils.getPremanagedScope( node );
+ String premanagedVersion = null; // DependencyManagerUtils.getPremanagedVersion( node );
+ String premanagedScope = null; // DependencyManagerUtils.getPremanagedScope( node );
DefaultDependencyNode current =
new DefaultDependencyNode( parent, artifact, premanagedVersion, premanagedScope,
diff --git a/src/main/java/org/apache/maven/shared/dependency/graph/internal/Maven3DependencyGraphBuilder.java b/src/main/java/org/apache/maven/shared/dependency/graph/internal/Maven3DependencyGraphBuilder.java
index 823b45c..df9d88f 100644
--- a/src/main/java/org/apache/maven/shared/dependency/graph/internal/Maven3DependencyGraphBuilder.java
+++ b/src/main/java/org/apache/maven/shared/dependency/graph/internal/Maven3DependencyGraphBuilder.java
@@ -66,6 +66,7 @@
private ArtifactFactory factory;
private final Invoker invoker = new Invoker();
+
private final ProjectReferenceKeyGenerator keyGenerator = new ProjectReferenceKeyGenerator();
public DependencyNode buildDependencyGraph( MavenProject project, ArtifactFilter filter )
@@ -74,24 +75,24 @@
return buildDependencyGraph( project, filter, Collections.EMPTY_MAP );
}
- public DependencyNode buildDependencyGraph(
- MavenProject project, ArtifactFilter filter, Map<String, MavenProject> reactorProjects )
- throws DependencyGraphBuilderException
+ public DependencyNode buildDependencyGraph( MavenProject project, ArtifactFilter filter,
+ Map<String, MavenProject> reactorProjects )
+ throws DependencyGraphBuilderException
{
ProjectBuildingRequest projectBuildingRequest =
- (ProjectBuildingRequest) invoke( project, "getProjectBuildingRequest" );
+ (ProjectBuildingRequest) invoke( project, "getProjectBuildingRequest" );
DependencyResolutionRequest request =
- new DefaultDependencyResolutionRequest( project, projectBuildingRequest.getRepositorySession() );
+ new DefaultDependencyResolutionRequest( project, projectBuildingRequest.getRepositorySession() );
final DependencyResolutionResult result = resolveDependencies( request, reactorProjects );
return buildDependencyNode( null, result.getDependencyGraph(), project.getArtifact(), filter );
}
- private DependencyResolutionResult resolveDependencies(DependencyResolutionRequest request,
- Map<String, MavenProject> reactorProjects)
- throws DependencyGraphBuilderException
+ private DependencyResolutionResult resolveDependencies( DependencyResolutionRequest request,
+ Map<String, MavenProject> reactorProjects )
+ throws DependencyGraphBuilderException
{
try
{
@@ -111,37 +112,44 @@
// NB There doesn't seem to be any way to apply this to Maven2DependencyGraphBuilder as there is no
// concept of partial resolution like there is is 3 and 3.1
final DependencyResolutionResult result = e.getResult();
- final List<Dependency> reactorDeps = getReactorDependencies( reactorProjects, result.getUnresolvedDependencies() );
+ final List<Dependency> reactorDeps =
+ getReactorDependencies( reactorProjects, result.getUnresolvedDependencies() );
invoker.invoke( result.getUnresolvedDependencies(), "removeAll", Collection.class, reactorDeps );
invoker.invoke( result.getResolvedDependencies(), "addAll", Collection.class, reactorDeps );
- if ( !result.getUnresolvedDependencies().isEmpty() ) {
+ if ( !result.getUnresolvedDependencies().isEmpty() )
+ {
throw new DependencyGraphBuilderException( "Could not resolve the following dependencies : "
- + result.getUnresolvedDependencies(), e );
+ + result.getUnresolvedDependencies(), e );
}
getLogger().debug( "Resolved dependencies after ignoring reactor dependencies : " + reactorDeps );
return result;
}
}
- private List<org.sonatype.aether.graph.Dependency> getReactorDependencies( Map<String, MavenProject> reactorProjects, List<?> dependencies )
+ private List<org.sonatype.aether.graph.Dependency> getReactorDependencies( Map<String, MavenProject> reactorProjects,
+ List<?> dependencies )
{
- final List<org.sonatype.aether.graph.Dependency> reactorDeps = new ArrayList<org.sonatype.aether.graph.Dependency>();
+ final List<org.sonatype.aether.graph.Dependency> reactorDeps =
+ new ArrayList<org.sonatype.aether.graph.Dependency>();
for ( final Object untypedDependency : dependencies )
{
- final org.sonatype.aether.graph.Dependency dependency = ( org.sonatype.aether.graph.Dependency ) untypedDependency;
+ final org.sonatype.aether.graph.Dependency dependency =
+ (org.sonatype.aether.graph.Dependency) untypedDependency;
final org.sonatype.aether.artifact.Artifact depArtifact = dependency.getArtifact();
- final String projectRefId = keyGenerator.getProjectReferenceKey(
- depArtifact.getGroupId(), depArtifact.getArtifactId(), depArtifact.getVersion()
- );
- if ( reactorProjects.containsKey( projectRefId ) ) {
+ final String projectRefId =
+ keyGenerator.getProjectReferenceKey( depArtifact.getGroupId(), depArtifact.getArtifactId(),
+ depArtifact.getVersion() );
+ if ( reactorProjects.containsKey( projectRefId ) )
+ {
reactorDeps.add( dependency );
}
}
return reactorDeps;
}
- private Object invoke( Object object, String method ) throws DependencyGraphBuilderException
+ private Object invoke( Object object, String method )
+ throws DependencyGraphBuilderException
{
try
{
@@ -175,7 +183,11 @@
Artifact artifact, ArtifactFilter filter )
{
DefaultDependencyNode current =
- new DefaultDependencyNode( parent, artifact, null /*node.getPremanagedVersion()*/, null /*node.getPremanagedScope()*/,
+ new DefaultDependencyNode( parent, artifact, null /* node.getPremanagedVersion() */, null /*
+ * node.
+ * getPremanagedScope
+ * ()
+ */,
getVersionSelectedFromRange( node.getVersionConstraint() ) );
List<DependencyNode> nodes = new ArrayList<DependencyNode>( node.getChildren().size() );
diff --git a/src/main/java/org/apache/maven/shared/dependency/graph/traversal/BuildingDependencyNodeVisitor.java b/src/main/java/org/apache/maven/shared/dependency/graph/traversal/BuildingDependencyNodeVisitor.java
index 0085540..700a2dc 100644
--- a/src/main/java/org/apache/maven/shared/dependency/graph/traversal/BuildingDependencyNodeVisitor.java
+++ b/src/main/java/org/apache/maven/shared/dependency/graph/traversal/BuildingDependencyNodeVisitor.java
@@ -65,8 +65,8 @@
* 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
+ * @param visitor the dependency node visitor to apply on the resultant dependency tree, or <code>null</code> for
+ * none
*/
public BuildingDependencyNodeVisitor( DependencyNodeVisitor visitor )
{
diff --git a/src/main/java/org/apache/maven/shared/dependency/graph/traversal/DependencyNodeVisitor.java b/src/main/java/org/apache/maven/shared/dependency/graph/traversal/DependencyNodeVisitor.java
index 7e271d7..f50a8ae 100644
--- a/src/main/java/org/apache/maven/shared/dependency/graph/traversal/DependencyNodeVisitor.java
+++ b/src/main/java/org/apache/maven/shared/dependency/graph/traversal/DependencyNodeVisitor.java
@@ -33,8 +33,7 @@
/**
* Starts the visit to the specified dependency node.
*
- * @param node
- * the dependency node to visit
+ * @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
*/
@@ -43,10 +42,9 @@
/**
* 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
+ * @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/src/main/java/org/apache/maven/shared/dependency/graph/traversal/FilteringDependencyNodeVisitor.java b/src/main/java/org/apache/maven/shared/dependency/graph/traversal/FilteringDependencyNodeVisitor.java
index 5131af5..3238a14 100644
--- a/src/main/java/org/apache/maven/shared/dependency/graph/traversal/FilteringDependencyNodeVisitor.java
+++ b/src/main/java/org/apache/maven/shared/dependency/graph/traversal/FilteringDependencyNodeVisitor.java
@@ -50,10 +50,8 @@
* 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
+ * @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 )
{
diff --git a/src/main/java/org/apache/maven/shared/dependency/graph/traversal/SerializingDependencyNodeVisitor.java b/src/main/java/org/apache/maven/shared/dependency/graph/traversal/SerializingDependencyNodeVisitor.java
index 6f5e5c1..ea4ed2f 100644
--- a/src/main/java/org/apache/maven/shared/dependency/graph/traversal/SerializingDependencyNodeVisitor.java
+++ b/src/main/java/org/apache/maven/shared/dependency/graph/traversal/SerializingDependencyNodeVisitor.java
@@ -82,8 +82,8 @@
/**
* The extended ASCII tokens to use when outputing the dependency graph.
*/
- public static final GraphTokens EXTENDED_TOKENS =
- new GraphTokens( "\u00c3\u00c4 ", "\u00c0\u00c4 ", "\u00b3 ", " " );
+ public static final GraphTokens EXTENDED_TOKENS = new GraphTokens( "\u00c3\u00c4 ", "\u00c0\u00c4 ", "\u00b3 ",
+ " " );
// fields -----------------------------------------------------------------
@@ -107,8 +107,7 @@
/**
* Creates a dependency node visitor that serializes visited nodes to the specified writer using whitespace tokens.
*
- * @param writer
- * the writer to serialize to
+ * @param writer the writer to serialize to
*/
public SerializingDependencyNodeVisitor( Writer writer )
{
@@ -119,10 +118,8 @@
* 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 graph
+ * @param writer the writer to serialize to
+ * @param tokens the tokens to use when serializing the dependency graph
*/
public SerializingDependencyNodeVisitor( Writer writer, GraphTokens tokens )
{
@@ -171,8 +168,7 @@
/**
* Writes the necessary tokens to indent the specified dependency node to this visitor's writer.
*
- * @param node
- * the dependency node to indent
+ * @param node the dependency node to indent
*/
private void indent( DependencyNode node )
{
@@ -190,14 +186,13 @@
/**
* Gets whether the specified dependency node is the last of its siblings.
*
- * @param node
- * the dependency node to check
+ * @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;
@@ -219,16 +214,14 @@
/**
* 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
+ * @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 )
diff --git a/src/main/java/org/apache/maven/shared/dependency/tree/DefaultDependencyTreeBuilder.java b/src/main/java/org/apache/maven/shared/dependency/tree/DefaultDependencyTreeBuilder.java
index 308173d..4293b3e 100644
--- a/src/main/java/org/apache/maven/shared/dependency/tree/DefaultDependencyTreeBuilder.java
+++ b/src/main/java/org/apache/maven/shared/dependency/tree/DefaultDependencyTreeBuilder.java
@@ -65,9 +65,9 @@
private ArtifactCollector collector;
// fields -----------------------------------------------------------------
-
+
private ArtifactResolutionResult result;
-
+
// DependencyTreeBuilder methods ------------------------------------------
/**
@@ -87,7 +87,7 @@
return new DependencyTree( rootNode, collectingVisitor.getNodes() );
}
-
+
/**
* {@inheritDoc}
*/
@@ -140,7 +140,8 @@
metadataSource, null, collector );
}
- public DependencyNode buildDependencyTree( MavenProject project, ArtifactRepository repository, ArtifactFilter filter )
+ public DependencyNode buildDependencyTree( MavenProject project, ArtifactRepository repository,
+ ArtifactFilter filter )
throws DependencyTreeBuilderException
{
return buildDependencyTree( project, repository, factory, metadataSource, filter, collector );
diff --git a/src/main/java/org/apache/maven/shared/dependency/tree/DependencyNode.java b/src/main/java/org/apache/maven/shared/dependency/tree/DependencyNode.java
index a73953f..5f989cb 100644
--- a/src/main/java/org/apache/maven/shared/dependency/tree/DependencyNode.java
+++ b/src/main/java/org/apache/maven/shared/dependency/tree/DependencyNode.java
@@ -69,66 +69,66 @@
* @since 1.1
*/
public static final int OMITTED_FOR_CYCLE = 3;
-
+
// classes ----------------------------------------------------------------
-
+
/**
- * Utility class to concatenate a number of parameters with separator tokens.
+ * 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;
}
}
@@ -151,8 +151,8 @@
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>.
+ * 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
@@ -163,11 +163,11 @@
/**
* 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>.
+ * <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.
@@ -175,8 +175,8 @@
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.
+ * 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;
@@ -185,7 +185,7 @@
* 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.
@@ -193,7 +193,7 @@
private String premanagedScope;
private VersionRange versionSelectedFromRange;
-
+
private List<ArtifactVersion> availableVersions;
// constructors -----------------------------------------------------------
@@ -201,10 +201,8 @@
/**
* 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
+ * @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 )
@@ -215,13 +213,10 @@
/**
* 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
+ * @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
+ * @throws IllegalArgumentException if the parameter constraints were violated
* @since 1.1
*/
public DependencyNode( Artifact artifact, int state )
@@ -232,19 +227,15 @@
/**
* 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>,
+ * @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
+ * @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
+ * @throws IllegalArgumentException if the parameter constraints were violated
* @since 1.1
*/
public DependencyNode( Artifact artifact, int state, Artifact relatedArtifact )
@@ -264,13 +255,13 @@
if ( requiresRelatedArtifact && relatedArtifact == null )
{
throw new IllegalArgumentException( "Related artifact is required for states "
- + "OMITTED_FOR_DUPLICATE and OMITTED_FOR_CONFLICT" );
+ + "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" );
+ + "OMITTED_FOR_DUPLICATE and OMITTED_FOR_CONFLICT" );
}
this.artifact = artifact;
@@ -279,7 +270,7 @@
children = new ArrayList<DependencyNode>();
}
-
+
/**
* Creates a new dependency node.
*
@@ -296,8 +287,7 @@
/**
* Applies the specified dependency node visitor to this dependency node and its children.
*
- * @param visitor
- * the dependency node visitor to use
+ * @param visitor the dependency node visitor to use
* @return the visitor result of ending the visit to this node
* @since 1.1
*/
@@ -320,8 +310,7 @@
/**
* Adds the specified dependency node to this dependency node's children.
*
- * @param child
- * the child dependency node to add
+ * @param child the child dependency node to add
* @since 1.1
*/
public void addChild( DependencyNode child )
@@ -333,8 +322,7 @@
/**
* Removes the specified dependency node from this dependency node's children.
*
- * @param child
- * the child dependency node to remove
+ * @param child the child dependency node to remove
* @since 1.1
*/
public void removeChild( DependencyNode child )
@@ -362,30 +350,29 @@
{
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
- * serializing 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.
+ * @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 serializing 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;
}
@@ -418,8 +405,8 @@
/**
* 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>.
+ * <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
@@ -428,7 +415,7 @@
{
return relatedArtifact;
}
-
+
/**
* Gets the scope of this node's artifact before it was updated due to conflicts.
*
@@ -443,8 +430,7 @@
/**
* 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
+ * @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 )
@@ -466,15 +452,15 @@
/**
* 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
+ * @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.
*
@@ -489,15 +475,15 @@
/**
* 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
+ * @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.
*
@@ -508,12 +494,11 @@
{
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
+ * @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 )
@@ -532,7 +517,7 @@
{
return versionSelectedFromRange;
}
-
+
public void setVersionSelectedFromRange( VersionRange versionSelectedFromRange )
{
this.versionSelectedFromRange = versionSelectedFromRange;
@@ -549,7 +534,7 @@
{
return availableVersions;
}
-
+
public void setAvailableVersions( List<ArtifactVersion> availableVersions )
{
this.availableVersions = availableVersions;
@@ -558,20 +543,16 @@
/**
* 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
+ * @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
@@ -616,13 +597,11 @@
/**
* 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>
+ * @throws IllegalStateException if this dependency node's state is not <code>INCLUDED</code>
* @see #OMITTED_FOR_CYCLE
* @since 1.1
*/
@@ -637,7 +616,7 @@
removeAllChildren();
}
-
+
/**
* Gets an iterator that returns this dependency node and it's children in preorder traversal.
*
@@ -690,40 +669,40 @@
}
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;
@@ -736,9 +715,9 @@
appender.append( "omitted for cycle" );
break;
}
-
+
appender.flush();
-
+
if ( !included )
{
buffer.append( ')' );
@@ -746,16 +725,14 @@
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
+ * @param indentDepth the indentation depth
* @return the string representation
* @deprecated As of 1.1, replaced by {@link #toString()}
*/
@@ -763,7 +740,7 @@
{
return toString();
}
-
+
// Object methods ---------------------------------------------------------
/**
@@ -772,16 +749,16 @@
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() );
@@ -799,7 +776,7 @@
public boolean equals( Object object )
{
// TODO: probably better using commons-lang EqualsBuilder
-
+
boolean equal;
if ( object instanceof DependencyNode )
@@ -809,10 +786,10 @@
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() );
@@ -863,8 +840,7 @@
/**
* Computes a hash-code for the specified object.
*
- * @param a
- * the object to compute a hash-code for, possibly <code>null</code>
+ * @param a the object to compute a hash-code for, possibly <code>null</code>
* @return the computed hash-code
*/
private int nullHashCode( Object a )
@@ -875,22 +851,19 @@
/**
* 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>
+ * @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>
+ * @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 )
diff --git a/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreeBuilder.java b/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreeBuilder.java
index fad4ffb..d7f9453 100644
--- a/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreeBuilder.java
+++ b/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreeBuilder.java
@@ -27,10 +27,10 @@
import org.apache.maven.project.MavenProject;
/**
- * Builds a tree of dependencies for a given Maven 2 project. Notice that it doesn't fail with Maven 3,
- * but when Maven 2 and Maven 3 don't calculate the same transitive dependency result, the tree calculated
- * with this component is consistent with Maven 2 even if run with Maven 3 (see
- * <a href="http://jira.codehaus.org/browse/MSHARED-167">MSHARED-167</a>.
+ * Builds a tree of dependencies for a given Maven 2 project. Notice that it doesn't fail with Maven 3, but when Maven 2
+ * and Maven 3 don't calculate the same transitive dependency result, the tree calculated with this component is
+ * consistent with Maven 2 even if run with Maven 3 (see <a
+ * href="http://jira.codehaus.org/browse/MSHARED-167">MSHARED-167</a>.
*
* @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
* @version $Id$
@@ -49,19 +49,13 @@
/**
* 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
+ * @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
+ * @throws DependencyTreeBuilderException if the dependency tree cannot be resolved
* @deprecated As of 1.1, replaced by
* {@link #buildDependencyTree(MavenProject, ArtifactRepository, ArtifactFactory, ArtifactMetadataSource, ArtifactFilter, ArtifactCollector)}
*/
@@ -72,21 +66,14 @@
/**
* 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
+ * @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
+ * @throws DependencyTreeBuilderException if the dependency tree cannot be resolved
* @since 1.1
*/
DependencyNode buildDependencyTree( MavenProject project, ArtifactRepository repository, ArtifactFactory factory,
diff --git a/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreeBuilderException.java b/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreeBuilderException.java
index fdd383f..b4b2836 100644
--- a/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreeBuilderException.java
+++ b/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreeBuilderException.java
@@ -25,7 +25,8 @@
* @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
* @version $Id$
*/
-public class DependencyTreeBuilderException extends Exception
+public class DependencyTreeBuilderException
+ extends Exception
{
// constants --------------------------------------------------------------
diff --git a/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreeInverseIterator.java b/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreeInverseIterator.java
index 005387e..bb93c6a 100644
--- a/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreeInverseIterator.java
+++ b/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreeInverseIterator.java
@@ -24,10 +24,9 @@
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()}
+ * {@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$
diff --git a/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreeResolutionListener.java b/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreeResolutionListener.java
index ceb1585..d9fe855 100644
--- a/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreeResolutionListener.java
+++ b/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreeResolutionListener.java
@@ -44,7 +44,7 @@
implements ResolutionListener, ResolutionListenerForDepMgmt
{
// fields -----------------------------------------------------------------
-
+
/**
* The log to write debug messages to.
*/
@@ -69,7 +69,7 @@
* The dependency node currently being processed by this listener.
*/
private DependencyNode currentNode;
-
+
/**
* Map < String replacementId, String premanaged version >
*/
@@ -85,13 +85,12 @@
/**
* Creates a new dependency tree resolution listener that writes to the specified log.
*
- * @param logger
- * the log to write debug messages to
+ * @param logger the log to write debug messages to
*/
public DependencyTreeResolutionListener( Logger logger )
{
this.logger = logger;
-
+
parentNodes = new Stack<DependencyNode>();
nodesByArtifact = new IdentityHashMap<Artifact, DependencyNode>();
rootNode = null;
@@ -114,11 +113,11 @@
public void startProcessChildren( Artifact artifact )
{
log( "startProcessChildren: artifact=" + artifact );
-
+
if ( !currentNode.getArtifact().equals( artifact ) )
{
throw new IllegalStateException( "Artifact was expected to be " + currentNode.getArtifact() + " but was "
- + artifact );
+ + artifact );
}
parentNodes.push( currentNode );
@@ -132,7 +131,7 @@
DependencyNode node = parentNodes.pop();
log( "endProcessChildren: artifact=" + artifact );
-
+
if ( node == null )
{
throw new IllegalStateException( "Parent dependency node was null" );
@@ -141,7 +140,7 @@
if ( !node.getArtifact().equals( artifact ) )
{
throw new IllegalStateException( "Parent dependency node artifact was expected to be " + node.getArtifact()
- + " but was " + artifact );
+ + " but was " + artifact );
}
}
@@ -151,7 +150,7 @@
public void includeArtifact( Artifact artifact )
{
log( "includeArtifact: artifact=" + artifact );
-
+
DependencyNode existingNode = getNode( artifact );
/*
@@ -176,12 +175,12 @@
public void omitForNearer( Artifact omitted, Artifact kept )
{
log( "omitForNearer: omitted=" + omitted + " kept=" + kept );
-
+
if ( !omitted.getDependencyConflictId().equals( kept.getDependencyConflictId() ) )
{
throw new IllegalArgumentException( "Omitted artifact dependency conflict id "
- + omitted.getDependencyConflictId() + " differs from kept artifact dependency conflict id "
- + kept.getDependencyConflictId() );
+ + omitted.getDependencyConflictId() + " differs from kept artifact dependency conflict id "
+ + kept.getDependencyConflictId() );
}
if ( isCurrentNodeIncluded() )
@@ -200,15 +199,15 @@
}
omittedNode.omitForConflict( kept );
-
+
/*
* Add the dependency management information cached in any prior manageArtifact calls, since omitForNearer
* is always called after manageArtifact.
*/
flushDependencyManagement( omittedNode );
-
+
DependencyNode keptNode = getNode( kept );
-
+
if ( keptNode == null )
{
addNode( kept );
@@ -222,7 +221,7 @@
public void updateScope( Artifact artifact, String scope )
{
log( "updateScope: artifact=" + artifact + ", scope=" + scope );
-
+
DependencyNode node = getNode( artifact );
if ( node == null )
@@ -240,14 +239,14 @@
public void manageArtifact( Artifact artifact, Artifact replacement )
{
// TODO: remove when ResolutionListenerForDepMgmt merged into ResolutionListener
-
+
log( "manageArtifact: artifact=" + artifact + ", replacement=" + replacement );
-
+
if ( replacement.getVersion() != null )
{
manageArtifactVersion( artifact, replacement );
}
-
+
if ( replacement.getScope() != null )
{
manageArtifactScope( artifact, replacement );
@@ -260,7 +259,7 @@
public void omitForCycle( Artifact artifact )
{
log( "omitForCycle: artifact=" + artifact );
-
+
if ( isCurrentNodeIncluded() )
{
DependencyNode node = createNode( artifact );
@@ -275,7 +274,7 @@
public void updateScopeCurrentPom( Artifact artifact, String scopeIgnored )
{
log( "updateScopeCurrentPom: artifact=" + artifact + ", scopeIgnored=" + scopeIgnored );
-
+
DependencyNode node = getNode( artifact );
if ( node == null )
@@ -315,19 +314,19 @@
public void restrictRange( Artifact artifact, Artifact replacement, VersionRange versionRange )
{
log( "restrictRange: artifact=" + artifact + ", replacement=" + replacement + ", versionRange=" + versionRange );
-
+
// TODO: track range restriction in node (MNG-3093)
}
-
+
// ResolutionListenerForDepMgmt methods -----------------------------------
-
+
/**
* {@inheritDoc}
*/
public void manageArtifactVersion( Artifact artifact, Artifact replacement )
{
log( "manageArtifactVersion: artifact=" + artifact + ", replacement=" + replacement );
-
+
/*
* DefaultArtifactCollector calls manageArtifact twice: first with the change; then subsequently with no change.
* We ignore the second call when the versions are equal.
@@ -348,7 +347,7 @@
public void manageArtifactScope( Artifact artifact, Artifact replacement )
{
log( "manageArtifactScope: artifact=" + artifact + ", replacement=" + replacement );
-
+
/*
* DefaultArtifactCollector calls manageArtifact twice: first with the change; then subsequently with no change.
* We ignore the second call when the scopes are equal.
@@ -362,7 +361,7 @@
managedScopes.put( replacement.getId(), artifact.getScope() );
}
}
-
+
// public methods ---------------------------------------------------------
/**
@@ -387,12 +386,11 @@
}
// private methods --------------------------------------------------------
-
+
/**
* Writes the specified message to the log at debug level with indentation for the current node's depth.
*
- * @param message
- * the message to write to the log
+ * @param message the message to write to the log
*/
private void log( String message )
{
@@ -413,8 +411,7 @@
/**
* Creates a new dependency node for the specified artifact and appends it to the current parent dependency node.
*
- * @param artifact
- * the attached artifact for the new dependency node
+ * @param artifact the attached artifact for the new dependency node
* @return the new dependency node
*/
private DependencyNode createNode( Artifact artifact )
@@ -430,13 +427,12 @@
return node;
}
-
+
/**
* Creates a new dependency node for the specified artifact, appends it to the current parent dependency node and
* puts it into the dependency node cache.
*
- * @param artifact
- * the attached artifact for the new dependency node
+ * @param artifact the attached artifact for the new dependency node
* @return the new dependency node
*/
// package protected for unit test
@@ -445,29 +441,27 @@
DependencyNode node = createNode( artifact );
DependencyNode previousNode = nodesByArtifact.put( node.getArtifact(), node );
-
+
if ( previousNode != null )
{
throw new IllegalStateException( "Duplicate node registered for artifact: " + node.getArtifact() );
}
-
+
if ( rootNode == null )
{
rootNode = node;
}
currentNode = node;
-
+
return node;
}
/**
* Gets the dependency node for the specified artifact from the dependency node cache.
*
- * @param artifact
- * the artifact to find the dependency node for
- * @return the dependency node, or <code>null</code> if the specified artifact has no corresponding dependency
- * node
+ * @param artifact the artifact to find the dependency node for
+ * @return the dependency node, or <code>null</code> if the specified artifact has no corresponding dependency node
*/
private DependencyNode getNode( Artifact artifact )
{
@@ -477,8 +471,7 @@
/**
* Removes the dependency node for the specified artifact from the dependency node cache.
*
- * @param artifact
- * the artifact to remove the dependency node for
+ * @param artifact the artifact to remove the dependency node for
*/
private void removeNode( Artifact artifact )
{
@@ -487,7 +480,7 @@
if ( !artifact.equals( node.getArtifact() ) )
{
throw new IllegalStateException( "Removed dependency node artifact was expected to be " + artifact
- + " but was " + node.getArtifact() );
+ + " but was " + node.getArtifact() );
}
}
@@ -515,27 +508,26 @@
* Updates the specified node with any dependency management information cached in prior <code>manageArtifact</code>
* calls.
*
- * @param node
- * the node to update
+ * @param node the node to update
*/
private void flushDependencyManagement( DependencyNode node )
{
Artifact artifact = node.getArtifact();
String premanagedVersion = managedVersions.get( artifact.getId() );
String premanagedScope = managedScopes.get( artifact.getId() );
-
+
if ( premanagedVersion != null || premanagedScope != null )
{
if ( premanagedVersion != null )
{
node.setPremanagedVersion( premanagedVersion );
}
-
+
if ( premanagedScope != null )
{
node.setPremanagedScope( premanagedScope );
}
-
+
premanagedVersion = null;
premanagedScope = null;
}
diff --git a/src/main/java/org/apache/maven/shared/dependency/tree/filter/AncestorOrSelfDependencyNodeFilter.java b/src/main/java/org/apache/maven/shared/dependency/tree/filter/AncestorOrSelfDependencyNodeFilter.java
index decd78f..c72d9aa 100644
--- a/src/main/java/org/apache/maven/shared/dependency/tree/filter/AncestorOrSelfDependencyNodeFilter.java
+++ b/src/main/java/org/apache/maven/shared/dependency/tree/filter/AncestorOrSelfDependencyNodeFilter.java
@@ -52,8 +52,7 @@
* 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
+ * @param descendantNodes the list of nodes to accept ancestors-or-self of
*/
public AncestorOrSelfDependencyNodeFilter( List<DependencyNode> descendantNodes )
{
@@ -83,12 +82,9 @@
/**
* 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>
+ * @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 )
{
diff --git a/src/main/java/org/apache/maven/shared/dependency/tree/filter/AndDependencyNodeFilter.java b/src/main/java/org/apache/maven/shared/dependency/tree/filter/AndDependencyNodeFilter.java
index d1dfad9..1202c23 100644
--- a/src/main/java/org/apache/maven/shared/dependency/tree/filter/AndDependencyNodeFilter.java
+++ b/src/main/java/org/apache/maven/shared/dependency/tree/filter/AndDependencyNodeFilter.java
@@ -47,10 +47,8 @@
/**
* 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
+ * @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 )
{
@@ -60,8 +58,7 @@
/**
* 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
+ * @param filters the list of dependency node filters to logically AND together
*/
public AndDependencyNodeFilter( List<DependencyNodeFilter> filters )
{
diff --git a/src/main/java/org/apache/maven/shared/dependency/tree/filter/ArtifactDependencyNodeFilter.java b/src/main/java/org/apache/maven/shared/dependency/tree/filter/ArtifactDependencyNodeFilter.java
index 231f6ee..cac1f43 100644
--- a/src/main/java/org/apache/maven/shared/dependency/tree/filter/ArtifactDependencyNodeFilter.java
+++ b/src/main/java/org/apache/maven/shared/dependency/tree/filter/ArtifactDependencyNodeFilter.java
@@ -45,8 +45,7 @@
/**
* Creates a dependency node filter that delegates to the specified artifact filter.
*
- * @param filter
- * the artifact filter to delegate to
+ * @param filter the artifact filter to delegate to
*/
public ArtifactDependencyNodeFilter( ArtifactFilter filter )
{
diff --git a/src/main/java/org/apache/maven/shared/dependency/tree/filter/DependencyNodeFilter.java b/src/main/java/org/apache/maven/shared/dependency/tree/filter/DependencyNodeFilter.java
index 25b02fa..5fbe554 100644
--- a/src/main/java/org/apache/maven/shared/dependency/tree/filter/DependencyNodeFilter.java
+++ b/src/main/java/org/apache/maven/shared/dependency/tree/filter/DependencyNodeFilter.java
@@ -33,8 +33,7 @@
/**
* Gets whether this filter accepts the specified dependency node.
*
- * @param node
- * the dependency node to check
+ * @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/src/main/java/org/apache/maven/shared/dependency/tree/filter/StateDependencyNodeFilter.java b/src/main/java/org/apache/maven/shared/dependency/tree/filter/StateDependencyNodeFilter.java
index ad611d4..21756d4 100644
--- a/src/main/java/org/apache/maven/shared/dependency/tree/filter/StateDependencyNodeFilter.java
+++ b/src/main/java/org/apache/maven/shared/dependency/tree/filter/StateDependencyNodeFilter.java
@@ -52,10 +52,8 @@
/**
* 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
+ * @param state the state of dependency nodes to accept
+ * @throws IllegalArgumentException if the specified state is invalid
*/
public StateDependencyNodeFilter( int state )
{
diff --git a/src/main/java/org/apache/maven/shared/dependency/tree/traversal/BuildingDependencyNodeVisitor.java b/src/main/java/org/apache/maven/shared/dependency/tree/traversal/BuildingDependencyNodeVisitor.java
index bad8f0b..756405e 100644
--- a/src/main/java/org/apache/maven/shared/dependency/tree/traversal/BuildingDependencyNodeVisitor.java
+++ b/src/main/java/org/apache/maven/shared/dependency/tree/traversal/BuildingDependencyNodeVisitor.java
@@ -65,8 +65,8 @@
* 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
+ * @param visitor the dependency node visitor to apply on the resultant dependency tree, or <code>null</code> for
+ * none
*/
public BuildingDependencyNodeVisitor( DependencyNodeVisitor visitor )
{
diff --git a/src/main/java/org/apache/maven/shared/dependency/tree/traversal/DependencyNodeVisitor.java b/src/main/java/org/apache/maven/shared/dependency/tree/traversal/DependencyNodeVisitor.java
index 2299126..8ec30dc 100644
--- a/src/main/java/org/apache/maven/shared/dependency/tree/traversal/DependencyNodeVisitor.java
+++ b/src/main/java/org/apache/maven/shared/dependency/tree/traversal/DependencyNodeVisitor.java
@@ -33,8 +33,7 @@
/**
* Starts the visit to the specified dependency node.
*
- * @param node
- * the dependency node to visit
+ * @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
*/
@@ -43,10 +42,9 @@
/**
* 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
+ * @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/src/main/java/org/apache/maven/shared/dependency/tree/traversal/FilteringDependencyNodeVisitor.java b/src/main/java/org/apache/maven/shared/dependency/tree/traversal/FilteringDependencyNodeVisitor.java
index bbde004..1eac512 100644
--- a/src/main/java/org/apache/maven/shared/dependency/tree/traversal/FilteringDependencyNodeVisitor.java
+++ b/src/main/java/org/apache/maven/shared/dependency/tree/traversal/FilteringDependencyNodeVisitor.java
@@ -50,10 +50,8 @@
* 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
+ * @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 )
{
diff --git a/src/main/java/org/apache/maven/shared/dependency/tree/traversal/SerializingDependencyNodeVisitor.java b/src/main/java/org/apache/maven/shared/dependency/tree/traversal/SerializingDependencyNodeVisitor.java
index dde3c40..9e0d7a0 100644
--- a/src/main/java/org/apache/maven/shared/dependency/tree/traversal/SerializingDependencyNodeVisitor.java
+++ b/src/main/java/org/apache/maven/shared/dependency/tree/traversal/SerializingDependencyNodeVisitor.java
@@ -84,8 +84,8 @@
/**
* The extended ASCII tokens to use when outputing the dependency tree.
*/
- public static final TreeTokens EXTENDED_TOKENS =
- new TreeTokens( "\u00c3\u00c4 ", "\u00c0\u00c4 ", "\u00b3 ", " " );
+ public static final TreeTokens EXTENDED_TOKENS = new TreeTokens( "\u00c3\u00c4 ", "\u00c0\u00c4 ", "\u00b3 ",
+ " " );
// fields -----------------------------------------------------------------
@@ -109,8 +109,7 @@
/**
* Creates a dependency node visitor that serializes visited nodes to the specified writer using whitespace tokens.
*
- * @param writer
- * the writer to serialize to
+ * @param writer the writer to serialize to
*/
public SerializingDependencyNodeVisitor( Writer writer )
{
@@ -121,10 +120,8 @@
* 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
+ * @param writer the writer to serialize to
+ * @param tokens the tokens to use when serializing the dependency tree
*/
public SerializingDependencyNodeVisitor( Writer writer, TreeTokens tokens )
{
@@ -173,8 +170,7 @@
/**
* Writes the necessary tokens to indent the specified dependency node to this visitor's writer.
*
- * @param node
- * the dependency node to indent
+ * @param node the dependency node to indent
*/
private void indent( DependencyNode node )
{
@@ -192,14 +188,13 @@
/**
* Gets whether the specified dependency node is the last of its siblings.
*
- * @param node
- * the dependency node to check
+ * @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;
@@ -221,16 +216,14 @@
/**
* 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
+ * @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 )
diff --git a/src/test/java/org/apache/maven/shared/dependency/tree/AbstractDependencyNodeTest.java b/src/test/java/org/apache/maven/shared/dependency/tree/AbstractDependencyNodeTest.java
index 19283db..82ab94f 100644
--- a/src/test/java/org/apache/maven/shared/dependency/tree/AbstractDependencyNodeTest.java
+++ b/src/test/java/org/apache/maven/shared/dependency/tree/AbstractDependencyNodeTest.java
@@ -55,7 +55,7 @@
{
return null;
}
-
+
String[] tokens = id.split( ":" );
return createArtifact( get( tokens, 0 ), get( tokens, 1 ), get( tokens, 2 ), get( tokens, 3 ), get( tokens, 4 ) );
diff --git a/src/test/java/org/apache/maven/shared/dependency/tree/ArtifactMetadataSourceStub.java b/src/test/java/org/apache/maven/shared/dependency/tree/ArtifactMetadataSourceStub.java
index 8a0ff3b..5e18f27 100644
--- a/src/test/java/org/apache/maven/shared/dependency/tree/ArtifactMetadataSourceStub.java
+++ b/src/test/java/org/apache/maven/shared/dependency/tree/ArtifactMetadataSourceStub.java
@@ -42,9 +42,9 @@
implements ArtifactMetadataSource
{
// TODO: move to maven-plugin-testing-harness?
-
+
// fields -----------------------------------------------------------------
-
+
/**
* Map of resolution groups by artifact.
*/
@@ -56,7 +56,7 @@
private final Map<Artifact, List<ArtifactVersion>> availableVersionsByArtifact;
// constructors -----------------------------------------------------------
-
+
/**
* Creates a new artifact metadata source stub.
*/
@@ -75,13 +75,13 @@
throws ArtifactMetadataRetrievalException
{
ResolutionGroup resolution = resolutionGroupsByArtifact.get( artifact );
-
+
// if we return null then the artifact gets excluded in DefaultArtifactCollector
if ( resolution == null )
{
resolution = new ResolutionGroup( artifact, Collections.EMPTY_SET, Collections.EMPTY_LIST );
}
-
+
return resolution;
}
@@ -98,14 +98,12 @@
}
// public methods ---------------------------------------------------------
-
+
/**
* Adds the specified dependency artifacts for the specified artifact to this artifact metadata source stub.
*
- * @param artifact
- * the artifact to add metadata to
- * @param dependencyArtifacts
- * the set of artifacts to register as dependencies of the specified artifact
+ * @param artifact the artifact to add metadata to
+ * @param dependencyArtifacts the set of artifacts to register as dependencies of the specified artifact
*/
public void addArtifactMetadata( Artifact artifact, Set<Artifact> dependencyArtifacts )
{
@@ -117,10 +115,8 @@
/**
* Adds versions for the specified artifact to this artifact metadata source stub.
*
- * @param artifact
- * the artifact to add metadata to
- * @param versions
- * the list of versions to register as available for the specified artifact
+ * @param artifact the artifact to add metadata to
+ * @param versions the list of versions to register as available for the specified artifact
*/
public void addAvailableVersions( Artifact artifact, List<ArtifactVersion> versions )
{
diff --git a/src/test/java/org/apache/maven/shared/dependency/tree/DefaultDependencyTreeBuilderTest.java b/src/test/java/org/apache/maven/shared/dependency/tree/DefaultDependencyTreeBuilderTest.java
index acdd467..62bdf75 100644
--- a/src/test/java/org/apache/maven/shared/dependency/tree/DefaultDependencyTreeBuilderTest.java
+++ b/src/test/java/org/apache/maven/shared/dependency/tree/DefaultDependencyTreeBuilderTest.java
@@ -112,7 +112,7 @@
* \- g:a:t:1
* </pre>
*
- * @throws DependencyTreeBuilderException
+ * @throws DependencyTreeBuilderException
*/
public void testProjectWithDependency()
throws DependencyTreeBuilderException
@@ -190,7 +190,8 @@
child1ArtifactNode.addChild( transitiveArtifactNode );
DependencyNode child2ArtifactNode = createNode( "g:b:t:1" );
expectedRootNode.addChild( child2ArtifactNode );
- child2ArtifactNode.addChild( createNode( "g:c:t:1", DependencyNode.OMITTED_FOR_DUPLICATE, transitiveArtifactNode.getArtifact() ) );
+ child2ArtifactNode.addChild( createNode( "g:c:t:1", DependencyNode.OMITTED_FOR_DUPLICATE,
+ transitiveArtifactNode.getArtifact() ) );
assertDependencyTree( expectedRootNode, project );
}
@@ -224,7 +225,8 @@
expectedRootNode.addChild( nearestArtifactNode );
DependencyNode childArtifactNode = createNode( "g:b:t:1" );
expectedRootNode.addChild( childArtifactNode );
- childArtifactNode.addChild( createNode( "g:a:t:2", DependencyNode.OMITTED_FOR_CONFLICT, nearestArtifactNode.getArtifact() ) );
+ childArtifactNode.addChild( createNode( "g:a:t:2", DependencyNode.OMITTED_FOR_CONFLICT,
+ nearestArtifactNode.getArtifact() ) );
assertDependencyTree( expectedRootNode, project );
}
@@ -258,7 +260,8 @@
expectedRootNode.addChild( childArtifactNode );
DependencyNode farthestArtifactNode = createNode( "g:b:t:1" );
expectedRootNode.addChild( farthestArtifactNode );
- childArtifactNode.addChild( createNode( "g:b:t:2", DependencyNode.OMITTED_FOR_CONFLICT, farthestArtifactNode.getArtifact() ) );
+ childArtifactNode.addChild( createNode( "g:b:t:2", DependencyNode.OMITTED_FOR_CONFLICT,
+ farthestArtifactNode.getArtifact() ) );
assertDependencyTree( expectedRootNode, project );
}
@@ -293,8 +296,9 @@
expectedRootNode.addChild( nearestArtifactNode );
DependencyNode childArtifactNode = createNode( "g:a:t:1" );
expectedRootNode.addChild( childArtifactNode );
- childArtifactNode.addChild( createNode( "g:b:t:1:compile", DependencyNode.OMITTED_FOR_DUPLICATE, nearestArtifactNode.getArtifact() ) );
-
+ childArtifactNode.addChild( createNode( "g:b:t:1:compile", DependencyNode.OMITTED_FOR_DUPLICATE,
+ nearestArtifactNode.getArtifact() ) );
+
assertDependencyTree( expectedRootNode, project );
}
@@ -326,30 +330,20 @@
MavenProject project = createProject( projectArtifact, new Artifact[] { childArtifact } );
/*
- * TODO: Not entirely convinced that the expected tree is correct - I would have expected:
- *
- * <pre>
- * g:p:t:1
- * \- g:a:t:1
- * +- g:b:t:1
- * | \- (g:c:t:1:compile - omitted for duplicate)
- * \- g:c:t:1:compile (scope updated from test)
- * </pre>
- *
+ * TODO: Not entirely convinced that the expected tree is correct - I would have expected: <pre> g:p:t:1 \-
+ * g:a:t:1 +- g:b:t:1 | \- (g:c:t:1:compile - omitted for duplicate) \- g:c:t:1:compile (scope updated from
+ * test) </pre>
* @see http://www.mail-archive.com/dev@maven.apache.org/msg68011.html
*/
/*
- DependencyNode expectedRootNode = createNode( "g:p:t:1" );
- DependencyNode childArtifactNode = createNode( "g:a:t:1" );
- expectedRootNode.addChild( childArtifactNode );
- DependencyNode grandchildArtifactNode = createNode( "g:b:t:1" );
- childArtifactNode.addChild( grandchildArtifactNode );
- DependencyNode nearestArtifactNode = createNode( "g:c:t:1:compile" );
- DependencyNode farthestArtifactNode = createNode( "g:c:t:1:compile", DependencyNode.OMITTED_FOR_DUPLICATE, nearestArtifactNode.getArtifact() );
- grandchildArtifactNode.addChild( farthestArtifactNode );
- nearestArtifactNode.setOriginalScope( "test" );
- childArtifactNode.addChild( nearestArtifactNode );
- */
+ * DependencyNode expectedRootNode = createNode( "g:p:t:1" ); DependencyNode childArtifactNode = createNode(
+ * "g:a:t:1" ); expectedRootNode.addChild( childArtifactNode ); DependencyNode grandchildArtifactNode =
+ * createNode( "g:b:t:1" ); childArtifactNode.addChild( grandchildArtifactNode ); DependencyNode
+ * nearestArtifactNode = createNode( "g:c:t:1:compile" ); DependencyNode farthestArtifactNode = createNode(
+ * "g:c:t:1:compile", DependencyNode.OMITTED_FOR_DUPLICATE, nearestArtifactNode.getArtifact() );
+ * grandchildArtifactNode.addChild( farthestArtifactNode ); nearestArtifactNode.setOriginalScope( "test" );
+ * childArtifactNode.addChild( nearestArtifactNode );
+ */
DependencyNode expectedRootNode = createNode( "g:p:t:1" );
DependencyNode childArtifactNode = createNode( "g:a:t:1" );
@@ -358,10 +352,11 @@
childArtifactNode.addChild( grandchildArtifactNode );
DependencyNode farthestArtifactNode = createNode( "g:c:t:1:compile" );
grandchildArtifactNode.addChild( farthestArtifactNode );
- DependencyNode nearestArtifactNode = createNode( "g:c:t:1:compile", DependencyNode.OMITTED_FOR_DUPLICATE, farthestArtifactNode.getArtifact() );
+ DependencyNode nearestArtifactNode =
+ createNode( "g:c:t:1:compile", DependencyNode.OMITTED_FOR_DUPLICATE, farthestArtifactNode.getArtifact() );
nearestArtifactNode.setOriginalScope( "test" );
childArtifactNode.addChild( nearestArtifactNode );
-
+
assertDependencyTree( expectedRootNode, project );
}
@@ -393,41 +388,32 @@
MavenProject project = createProject( projectArtifact, new Artifact[] { childArtifact } );
/*
- * TODO: Not entirely convinced that the expected tree is correct - I would have expected:
- *
- * <pre>
- * g:p:t:1
- * \- g:a:t:1
- * +- g:c:t:1:compile (scope updated from test)
- * \- g:b:t:1
- * \- (g:c:t:1:compile - omitted for duplicate)
+ * TODO: Not entirely convinced that the expected tree is correct - I would have expected: <pre> g:p:t:1 \-
+ * g:a:t:1 +- g:c:t:1:compile (scope updated from test) \- g:b:t:1 \- (g:c:t:1:compile - omitted for duplicate)
* </pre>
- *
* @see http://www.mail-archive.com/dev@maven.apache.org/msg68011.html
*/
/*
- DependencyNode expectedRootNode = createNode( "g:p:t:1" );
- DependencyNode childArtifactNode = createNode( "g:a:t:1" );
- expectedRootNode.addChild( childArtifactNode );
- DependencyNode nearestArtifactNode = createNode( "g:c:t:1:compile" );
- nearestArtifactNode.setOriginalScope( "test" );
- childArtifactNode.addChild( nearestArtifactNode );
- DependencyNode grandchildArtifactNode = createNode( "g:b:t:1" );
- childArtifactNode.addChild( grandchildArtifactNode );
- grandchildArtifactNode.addChild( createNode( "g:c:t:1:compile", DependencyNode.OMITTED_FOR_DUPLICATE, nearestArtifactNode.getArtifact() ) );
- */
-
+ * DependencyNode expectedRootNode = createNode( "g:p:t:1" ); DependencyNode childArtifactNode = createNode(
+ * "g:a:t:1" ); expectedRootNode.addChild( childArtifactNode ); DependencyNode nearestArtifactNode = createNode(
+ * "g:c:t:1:compile" ); nearestArtifactNode.setOriginalScope( "test" ); childArtifactNode.addChild(
+ * nearestArtifactNode ); DependencyNode grandchildArtifactNode = createNode( "g:b:t:1" );
+ * childArtifactNode.addChild( grandchildArtifactNode ); grandchildArtifactNode.addChild( createNode(
+ * "g:c:t:1:compile", DependencyNode.OMITTED_FOR_DUPLICATE, nearestArtifactNode.getArtifact() ) );
+ */
+
DependencyNode expectedRootNode = createNode( "g:p:t:1" );
DependencyNode childArtifactNode = createNode( "g:a:t:1" );
expectedRootNode.addChild( childArtifactNode );
DependencyNode farthestArtifactNode = createNode( "g:c:t:1:compile" );
- DependencyNode nearestArtifactNode = createNode( "g:c:t:1:compile", DependencyNode.OMITTED_FOR_DUPLICATE, farthestArtifactNode.getArtifact() );
+ DependencyNode nearestArtifactNode =
+ createNode( "g:c:t:1:compile", DependencyNode.OMITTED_FOR_DUPLICATE, farthestArtifactNode.getArtifact() );
nearestArtifactNode.setOriginalScope( "test" );
childArtifactNode.addChild( nearestArtifactNode );
DependencyNode grandchildArtifactNode = createNode( "g:b:t:1" );
childArtifactNode.addChild( grandchildArtifactNode );
grandchildArtifactNode.addChild( farthestArtifactNode );
-
+
assertDependencyTree( expectedRootNode, project );
}
@@ -467,7 +453,7 @@
// TODO: see MNG-3548
/**
- * Tests building a tree for a project with a dependency that is duplicated and the version is also fixed in
+ * Tests building a tree for a project with a dependency that is duplicated and the version is also fixed in
* dependency management:
*
* <pre>
@@ -481,36 +467,24 @@
* @throws DependencyTreeBuilderException
*/
/*
- public void testProjectWithManagedTransitiveDependencyVersionAndDuplicate() throws DependencyTreeBuilderException
- {
- Artifact projectArtifact = createArtifact( "g:p:t:1" );
- Artifact childArtifact = createArtifact( "g:a:t:1" );
- Artifact grandchildArtifact = createArtifact( "g:b:t:1" );
- Artifact farthestTransitiveArtifact = createArtifact( "g:c:t:1" );
- Artifact nearestTransitiveArtifact = createArtifact( "g:c:t:1" );
- Artifact managedTransitiveArtifact = createArtifact( "g:c:t:2" );
- addArtifactMetadata( childArtifact, new Artifact[] { grandchildArtifact, nearestTransitiveArtifact } );
- addArtifactMetadata( grandchildArtifact, farthestTransitiveArtifact );
-
- MavenProject project = createProject( projectArtifact, new Artifact[] { childArtifact } );
- setManagedVersionMap( project, Collections.singleton( managedTransitiveArtifact ) );
-
- DependencyNode expectedRootNode = createNode( "g:p:t:1" );
- DependencyNode childArtifactNode = createNode( "g:a:t:1" );
- expectedRootNode.addChild( childArtifactNode );
- DependencyNode grandchildArtifactNode = createNode( "g:b:t:2" );
- childArtifactNode.addChild( grandchildArtifactNode );
- DependencyNode managedTransitiveArtifactNode = createNode( "g:c:t:2" );
- managedTransitiveArtifactNode.setPremanagedVersion( "1" );
- childArtifactNode.addChild( managedTransitiveArtifactNode );
- DependencyNode omittedManagedTransitiveArtifactNode = createNode( "g:c:t:2" );
- omittedManagedTransitiveArtifactNode.setPremanagedVersion( "1" );
- omittedManagedTransitiveArtifactNode.omitForConflict( managedTransitiveArtifact );
- grandchildArtifactNode.addChild( omittedManagedTransitiveArtifactNode );
-
- assertDependencyTree( expectedRootNode, project );
- }
- */
+ * public void testProjectWithManagedTransitiveDependencyVersionAndDuplicate() throws DependencyTreeBuilderException
+ * { Artifact projectArtifact = createArtifact( "g:p:t:1" ); Artifact childArtifact = createArtifact( "g:a:t:1" );
+ * Artifact grandchildArtifact = createArtifact( "g:b:t:1" ); Artifact farthestTransitiveArtifact = createArtifact(
+ * "g:c:t:1" ); Artifact nearestTransitiveArtifact = createArtifact( "g:c:t:1" ); Artifact managedTransitiveArtifact
+ * = createArtifact( "g:c:t:2" ); addArtifactMetadata( childArtifact, new Artifact[] { grandchildArtifact,
+ * nearestTransitiveArtifact } ); addArtifactMetadata( grandchildArtifact, farthestTransitiveArtifact );
+ * MavenProject project = createProject( projectArtifact, new Artifact[] { childArtifact } ); setManagedVersionMap(
+ * project, Collections.singleton( managedTransitiveArtifact ) ); DependencyNode expectedRootNode = createNode(
+ * "g:p:t:1" ); DependencyNode childArtifactNode = createNode( "g:a:t:1" ); expectedRootNode.addChild(
+ * childArtifactNode ); DependencyNode grandchildArtifactNode = createNode( "g:b:t:2" ); childArtifactNode.addChild(
+ * grandchildArtifactNode ); DependencyNode managedTransitiveArtifactNode = createNode( "g:c:t:2" );
+ * managedTransitiveArtifactNode.setPremanagedVersion( "1" ); childArtifactNode.addChild(
+ * managedTransitiveArtifactNode ); DependencyNode omittedManagedTransitiveArtifactNode = createNode( "g:c:t:2" );
+ * omittedManagedTransitiveArtifactNode.setPremanagedVersion( "1" );
+ * omittedManagedTransitiveArtifactNode.omitForConflict( managedTransitiveArtifact );
+ * grandchildArtifactNode.addChild( omittedManagedTransitiveArtifactNode ); assertDependencyTree( expectedRootNode,
+ * project ); }
+ */
/**
* Tests building a tree for a project with one transitive dependency whose scope is fixed in dependency management:
@@ -579,7 +553,7 @@
assertDependencyTree( expectedRootNode, project );
}
-
+
/**
* Tests building a tree for a project with a dependency that has conflicting versions and the version is also fixed
* in dependency management:
@@ -611,14 +585,14 @@
expectedRootNode.addChild( nearestArtifactNode );
DependencyNode childArtifactNode = createNode( "g:b:t:1" );
expectedRootNode.addChild( childArtifactNode );
- DependencyNode managedTransitiveArtifactNode = createNode( "g:a:t:3", DependencyNode.OMITTED_FOR_CONFLICT, nearestArtifactNode.getArtifact() );
+ DependencyNode managedTransitiveArtifactNode =
+ createNode( "g:a:t:3", DependencyNode.OMITTED_FOR_CONFLICT, nearestArtifactNode.getArtifact() );
managedTransitiveArtifactNode.setPremanagedVersion( "2" );
childArtifactNode.addChild( managedTransitiveArtifactNode );
assertDependencyTree( expectedRootNode, project );
}
-
/**
* Tests building a tree for a project with a dependency with version range
*
@@ -627,15 +601,15 @@
* \- g:a:t:1
* </pre>
*
- * @throws InvalidVersionSpecificationException
- * @throws DependencyTreeBuilderException
+ * @throws InvalidVersionSpecificationException
+ * @throws DependencyTreeBuilderException
*/
public void testProjectWithVersionRange()
throws InvalidVersionSpecificationException, DependencyTreeBuilderException
{
String range = "[1,2)";
Artifact projectArtifact = createArtifact( "g:p:t:1" );
- Artifact childArtifact = createArtifact( "g:a:t:" + range);
+ Artifact childArtifact = createArtifact( "g:a:t:" + range );
MavenProject project = createProject( projectArtifact, new Artifact[] { childArtifact } );
@@ -655,35 +629,26 @@
// TODO: reinstate when MNG-3236 fixed
/*
- public void testProjectWithFilter() throws DependencyTreeBuilderException, ArtifactResolutionException
- {
- Artifact projectArtifact = createArtifact( "g:p:t:1" );
- Artifact child1Artifact = createArtifact( "g:a:t:1" );
- Artifact child2Artifact = createArtifact( "g:b:t:1:test" );
-
- MavenProject project = createProject( projectArtifact, new Artifact[] { child1Artifact, child2Artifact } );
-
- DependencyNode expectedRootNode = createNode( "g:p:t:1" );
- expectedRootNode.addChild( createNode( "g:a:t:1" ) );
-
- ArtifactFilter artifactFilter = new ScopeArtifactFilter( Artifact.SCOPE_COMPILE );
-
- assertDependencyTree( expectedRootNode, project, artifactFilter );
- }
- */
+ * public void testProjectWithFilter() throws DependencyTreeBuilderException, ArtifactResolutionException { Artifact
+ * projectArtifact = createArtifact( "g:p:t:1" ); Artifact child1Artifact = createArtifact( "g:a:t:1" ); Artifact
+ * child2Artifact = createArtifact( "g:b:t:1:test" ); MavenProject project = createProject( projectArtifact, new
+ * Artifact[] { child1Artifact, child2Artifact } ); DependencyNode expectedRootNode = createNode( "g:p:t:1" );
+ * expectedRootNode.addChild( createNode( "g:a:t:1" ) ); ArtifactFilter artifactFilter = new ScopeArtifactFilter(
+ * Artifact.SCOPE_COMPILE ); assertDependencyTree( expectedRootNode, project, artifactFilter ); }
+ */
// private methods --------------------------------------------------------
-
+
private DependencyNode createNode( String id )
{
return createNode( id, DependencyNode.INCLUDED, null );
}
-
+
private DependencyNode createNode( String id, int state, Artifact relatedArtifact )
{
return new DependencyNode( createArtifact( id ), state, relatedArtifact );
}
-
+
private Artifact createArtifact( String id )
{
String[] tokens = id.split( ":" );
@@ -693,7 +658,7 @@
String type = get( tokens, 2, "jar" );
String version = get( tokens, 3 );
String scope = get( tokens, 4 );
-
+
VersionRange versionRange;
try
{
@@ -701,12 +666,12 @@
}
catch ( InvalidVersionSpecificationException e )
{
- throw new RuntimeException(e);
+ throw new RuntimeException( e );
}
return new DefaultArtifact( groupId, artifactId, versionRange, scope, type, null, new DefaultArtifactHandler() );
}
-
+
private MavenProject createProject( Artifact projectArtifact, Artifact[] dependencyArtifacts )
{
MavenProject project = new MavenProject();
@@ -722,43 +687,43 @@
{
addArtifactMetadata( artifact, new Artifact[] { dependencyArtifact } );
}
-
+
private void addArtifactMetadata( Artifact artifact, Artifact[] dependencyArtifacts )
{
addArtifactMetadata( artifact, new LinkedHashSet<Artifact>( Arrays.asList( dependencyArtifacts ) ) );
}
-
+
private void addArtifactMetadata( Artifact artifact, Set<Artifact> dependencyArtifacts )
{
artifactMetadataSource.addArtifactMetadata( artifact, dependencyArtifacts );
}
-
+
private void setManagedVersionMap( MavenProject project, Set<Artifact> managedArtifacts )
{
Map<String, Artifact> managedVersionMap = new HashMap<String, Artifact>();
-
+
for ( Artifact artifact : managedArtifacts )
{
String managementKey = getManagementKey( artifact );
-
+
managedVersionMap.put( managementKey, artifact );
}
project.setManagedVersionMap( managedVersionMap );
}
-
+
private String getManagementKey( Artifact artifact )
{
return artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getType()
+ ( artifact.getClassifier() != null ? ":" + artifact.getClassifier() : "" );
}
-
+
private void assertDependencyTree( DependencyNode expectedRootNode, MavenProject project )
throws DependencyTreeBuilderException
{
assertDependencyTree( expectedRootNode, project, null );
}
-
+
private void assertDependencyTree( DependencyNode expectedRootNode, MavenProject project,
ArtifactFilter artifactFilter )
throws DependencyTreeBuilderException
@@ -777,7 +742,7 @@
assertTreeEquals( expectedRootNode, project, result );
}
-
+
private void assertTreeEquals( DependencyNode dependencyNode, MavenProject project,
ArtifactResolutionResult resolutionResult )
{
@@ -803,7 +768,7 @@
throw new AssertionFailedError( buffer.toString() );
}
}
-
+
private void assertNodesEquals( List<DependencyNode> dependencyNodes, List<ResolutionNode> resolutionNodes )
{
assertNodesEquals( dependencyNodes.iterator(), resolutionNodes.iterator() );
@@ -816,10 +781,10 @@
{
DependencyNode dependencyNode = dependencyNodesIterator.next();
ResolutionNode resolutionNode = resolutionNodesIterator.next();
-
+
assertNodeEquals( dependencyNode, resolutionNode );
}
-
+
if ( dependencyNodesIterator.hasNext() || resolutionNodesIterator.hasNext() )
{
fail( "Node list size differs" );
@@ -829,17 +794,17 @@
private void assertNodeEquals( DependencyNode dependencyNode, ResolutionNode resolutionNode )
{
assertEquals( "Node state", dependencyNode.getState() == DependencyNode.INCLUDED, resolutionNode.isActive() );
-
+
assertEquals( "Node artifact", dependencyNode.getArtifact(), resolutionNode.getArtifact() );
-
+
assertNodesEquals( dependencyNode.getChildren().iterator(), resolutionNode.getChildrenIterator() );
}
-
+
private String get( String[] array, int index )
{
return get( array, index, null );
}
-
+
private String get( String[] array, int index, String defaultValue )
{
return ( index < array.length ) ? array[index] : defaultValue;
diff --git a/src/test/java/org/apache/maven/shared/dependency/tree/DependencyNodeTest.java b/src/test/java/org/apache/maven/shared/dependency/tree/DependencyNodeTest.java
index f3719f3..5769d12 100644
--- a/src/test/java/org/apache/maven/shared/dependency/tree/DependencyNodeTest.java
+++ b/src/test/java/org/apache/maven/shared/dependency/tree/DependencyNodeTest.java
@@ -28,7 +28,7 @@
/**
* Tests <code>DependencyNode</code>.
- *
+ *
* @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
* @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
* @version $Id$
@@ -45,10 +45,7 @@
super.setUp();
/*
- * ------1------
- * ----2---- 3
- * 4 5 7
- * 6
+ * ------1------ ----2---- 3 4 5 7 6
*/
node1 = createNode( 1 );
@@ -95,12 +92,12 @@
assertNode( it, node1 );
assertFalse( it.hasNext() );
}
-
+
public void testToNodeStringIncluded()
{
Artifact artifact = createArtifact( "g:a:t:1:s" );
DependencyNode node = new DependencyNode( artifact );
-
+
assertEquals( "g:a:t:1:s", node.toNodeString() );
}
@@ -109,7 +106,7 @@
Artifact artifact = createArtifact( "g:a:t:1:s" );
DependencyNode node = new DependencyNode( artifact );
node.setPremanagedVersion( "2" );
-
+
assertEquals( "g:a:t:1:s (version managed from 2)", node.toNodeString() );
}
@@ -118,7 +115,7 @@
Artifact artifact = createArtifact( "g:a:t:1:s" );
DependencyNode node = new DependencyNode( artifact );
node.setPremanagedScope( "x" );
-
+
assertEquals( "g:a:t:1:s (scope managed from x)", node.toNodeString() );
}
@@ -127,7 +124,7 @@
Artifact artifact = createArtifact( "g:a:t:1:s" );
DependencyNode node = new DependencyNode( artifact );
node.setOriginalScope( "x" );
-
+
assertEquals( "g:a:t:1:s (scope updated from x)", node.toNodeString() );
}
@@ -136,7 +133,7 @@
Artifact artifact = createArtifact( "g:a:t:1:s" );
Artifact duplicateArtifact = createArtifact( "g:a:t:1:s" );
DependencyNode node = new DependencyNode( artifact, DependencyNode.OMITTED_FOR_DUPLICATE, duplicateArtifact );
-
+
assertEquals( "(g:a:t:1:s - omitted for duplicate)", node.toNodeString() );
}
@@ -146,7 +143,7 @@
Artifact duplicateArtifact = createArtifact( "g:a:t:1:s" );
DependencyNode node = new DependencyNode( artifact, DependencyNode.OMITTED_FOR_DUPLICATE, duplicateArtifact );
node.setOriginalScope( "x" );
-
+
assertEquals( "(g:a:t:1:s - scope updated from x; omitted for duplicate)", node.toNodeString() );
}
@@ -154,16 +151,16 @@
{
Artifact artifact = createArtifact( "g:a:t:1:s" );
Artifact conflictArtifact = createArtifact( "g:a:t:2:s" );
- DependencyNode node = new DependencyNode(artifact, DependencyNode.OMITTED_FOR_CONFLICT, conflictArtifact);
-
+ DependencyNode node = new DependencyNode( artifact, DependencyNode.OMITTED_FOR_CONFLICT, conflictArtifact );
+
assertEquals( "(g:a:t:1:s - omitted for conflict with 2)", node.toNodeString() );
}
public void testToNodeStringOmittedForCycle()
{
Artifact artifact = createArtifact( "g:a:t:1:s" );
- DependencyNode node = new DependencyNode(artifact, DependencyNode.OMITTED_FOR_CYCLE);
-
+ DependencyNode node = new DependencyNode( artifact, DependencyNode.OMITTED_FOR_CYCLE );
+
assertEquals( "(g:a:t:1:s - omitted for cycle)", node.toNodeString() );
}
@@ -180,28 +177,28 @@
assertLine( reader, 3, 1 );
assertLine( reader, 7, 2 );
}
-
+
public void testOmitForConflict()
{
Artifact relatedArtifact = createArtifact( createArtifactId( 2, "3" ) );
node2.omitForConflict( relatedArtifact );
-
+
assertEquals( DependencyNode.OMITTED_FOR_CONFLICT, node2.getState() );
assertEquals( relatedArtifact, node2.getRelatedArtifact() );
-
+
assertTrue( node2.getChildren().isEmpty() );
assertNull( node4.getParent() );
assertNull( node5.getParent() );
}
-
+
public void testOmitForConflictWithDuplicate()
{
Artifact relatedArtifact = createArtifact( createArtifactId( 2 ) );
node2.omitForConflict( relatedArtifact );
-
+
assertEquals( DependencyNode.OMITTED_FOR_DUPLICATE, node2.getState() );
assertEquals( relatedArtifact, node2.getRelatedArtifact() );
-
+
assertTrue( node2.getChildren().isEmpty() );
assertNull( node4.getParent() );
assertNull( node5.getParent() );
@@ -210,14 +207,14 @@
public void testOmitForCycle()
{
node2.omitForCycle();
-
+
assertEquals( DependencyNode.OMITTED_FOR_CYCLE, node2.getState() );
-
+
assertTrue( node2.getChildren().isEmpty() );
assertNull( node4.getParent() );
assertNull( node5.getParent() );
}
-
+
/**
* @deprecated
*/
@@ -255,9 +252,9 @@
private DependencyNode createNode( DependencyNode parent, int i )
{
DependencyNode node = createNode( i );
-
+
parent.addChild( node );
-
+
return node;
}
@@ -268,11 +265,11 @@
private String createArtifactId( int i )
{
- return createArtifactId( i, Integer.toString( i ) );
+ return createArtifactId( i, Integer.toString( i ) );
}
private String createArtifactId( int i, String version )
{
- return "groupId" + i + ":artifactId" + i + ":jar:" + version + ":compile";
+ return "groupId" + i + ":artifactId" + i + ":jar:" + version + ":compile";
}
}
diff --git a/src/test/java/org/apache/maven/shared/dependency/tree/DependencyTreeResolutionListenerTest.java b/src/test/java/org/apache/maven/shared/dependency/tree/DependencyTreeResolutionListenerTest.java
index 41d6086..9ad306a 100644
--- a/src/test/java/org/apache/maven/shared/dependency/tree/DependencyTreeResolutionListenerTest.java
+++ b/src/test/java/org/apache/maven/shared/dependency/tree/DependencyTreeResolutionListenerTest.java
@@ -45,7 +45,8 @@
/**
* {@inheritDoc}
*/
- protected void setUp() throws Exception
+ protected void setUp()
+ throws Exception
{
super.setUp();
@@ -195,7 +196,8 @@
listener.endProcessChildren( projectArtifact );
DependencyNode projectArtifactNode = new DependencyNode( projectArtifact );
- projectArtifactNode.addChild( new DependencyNode( depArtifact1, DependencyNode.OMITTED_FOR_DUPLICATE, depArtifact2 ) );
+ projectArtifactNode.addChild( new DependencyNode( depArtifact1, DependencyNode.OMITTED_FOR_DUPLICATE,
+ depArtifact2 ) );
projectArtifactNode.addChild( new DependencyNode( depArtifact2 ) );
assertEquals( projectArtifactNode, listener.getRootNode() );
@@ -232,7 +234,8 @@
listener.endProcessChildren( projectArtifact );
DependencyNode projectArtifactNode = new DependencyNode( projectArtifact );
- DependencyNode depArtifact1Node = new DependencyNode( depArtifact1, DependencyNode.OMITTED_FOR_DUPLICATE, depArtifact2 );
+ DependencyNode depArtifact1Node =
+ new DependencyNode( depArtifact1, DependencyNode.OMITTED_FOR_DUPLICATE, depArtifact2 );
projectArtifactNode.addChild( depArtifact1Node );
DependencyNode depArtifact2Node = new DependencyNode( depArtifact2 );
projectArtifactNode.addChild( depArtifact2Node );
diff --git a/src/test/java/org/apache/maven/shared/dependency/tree/ResolutionNodeUtils.java b/src/test/java/org/apache/maven/shared/dependency/tree/ResolutionNodeUtils.java
index 7b51293..c3d412a 100644
--- a/src/test/java/org/apache/maven/shared/dependency/tree/ResolutionNodeUtils.java
+++ b/src/test/java/org/apache/maven/shared/dependency/tree/ResolutionNodeUtils.java
@@ -42,23 +42,23 @@
public final class ResolutionNodeUtils
{
// constructors -----------------------------------------------------------
-
+
private ResolutionNodeUtils()
{
// private constructor for utility class
}
// public methods ---------------------------------------------------------
-
+
public static List<ResolutionNode> getRootChildrenResolutionNodes( MavenProject project,
ArtifactResolutionResult resolutionResult )
{
Set<ResolutionNode> resolutionNodes = resolutionResult.getArtifactResolutionNodes();
// obtain root children nodes
-
+
Map<Artifact, ResolutionNode> rootChildrenResolutionNodesByArtifact = new HashMap<Artifact, ResolutionNode>();
-
+
for ( ResolutionNode resolutionNode : resolutionNodes )
{
if ( resolutionNode.isChildOfRootNode() )
@@ -66,31 +66,31 @@
rootChildrenResolutionNodesByArtifact.put( resolutionNode.getArtifact(), resolutionNode );
}
}
-
+
// order root children by project dependencies
-
+
List<ResolutionNode> rootChildrenResolutionNodes = new ArrayList<ResolutionNode>();
-
+
for ( Iterator<Artifact> iterator = project.getDependencyArtifacts().iterator(); iterator.hasNext(); )
{
Artifact artifact = iterator.next();
ResolutionNode resolutionNode = rootChildrenResolutionNodesByArtifact.get( artifact );
-
+
rootChildrenResolutionNodes.add( resolutionNode );
}
return rootChildrenResolutionNodes;
}
-
+
public static String toString( MavenProject project, ArtifactResolutionResult result )
{
StringBuffer buffer = new StringBuffer();
-
+
append( buffer, project, result );
-
+
return buffer.toString();
}
-
+
public static StringBuffer append( StringBuffer buffer, MavenProject project, ArtifactResolutionResult result )
{
ResolutionNode rootNode = new ResolutionNode( project.getArtifact(), Collections.EMPTY_LIST );
@@ -98,21 +98,21 @@
List<ResolutionNode> rootChildrenNodes = getRootChildrenResolutionNodes( project, result );
append( buffer, rootChildrenNodes.iterator(), 1 );
-
+
return buffer;
}
-
+
// private methods --------------------------------------------------------
-
+
private static StringBuffer append( StringBuffer buffer, Iterator<ResolutionNode> nodesIterator, int depth )
{
while ( nodesIterator.hasNext() )
{
ResolutionNode node = nodesIterator.next();
-
+
append( buffer, node, depth );
}
-
+
return buffer;
}
@@ -122,15 +122,15 @@
{
buffer.append( " " );
}
-
+
buffer.append( node );
buffer.append( System.getProperty( "line.separator" ) );
-
+
if ( node != null && node.isResolved() )
{
append( buffer, node.getChildrenIterator(), depth + 1 );
}
-
+
return buffer;
}
}
diff --git a/src/test/java/org/apache/maven/shared/dependency/tree/filter/AncestorOrSelfDependencyNodeFilterTest.java b/src/test/java/org/apache/maven/shared/dependency/tree/filter/AncestorOrSelfDependencyNodeFilterTest.java
index 34770c8..4e22340 100644
--- a/src/test/java/org/apache/maven/shared/dependency/tree/filter/AncestorOrSelfDependencyNodeFilterTest.java
+++ b/src/test/java/org/apache/maven/shared/dependency/tree/filter/AncestorOrSelfDependencyNodeFilterTest.java
@@ -53,8 +53,7 @@
throws Exception
{
/*
- * p -> a -> c
- * -> b
+ * p -> a -> c -> b
*/
rootNode = createNode( "g:p:t:1" );
diff --git a/src/test/java/org/apache/maven/shared/dependency/tree/traversal/CollectingDependencyNodeVisitorTest.java b/src/test/java/org/apache/maven/shared/dependency/tree/traversal/CollectingDependencyNodeVisitorTest.java
index 447766b..50269fa 100644
--- a/src/test/java/org/apache/maven/shared/dependency/tree/traversal/CollectingDependencyNodeVisitorTest.java
+++ b/src/test/java/org/apache/maven/shared/dependency/tree/traversal/CollectingDependencyNodeVisitorTest.java
@@ -37,9 +37,9 @@
extends AbstractDependencyNodeTest
{
// fields -----------------------------------------------------------------
-
+
private CollectingDependencyNodeVisitor visitor;
-
+
private DependencyNode node1;
private DependencyNode node2;
@@ -47,7 +47,7 @@
private DependencyNode node3;
// TestCase methods -------------------------------------------------------
-
+
/**
* {@inheritDoc}
*/
@@ -59,9 +59,9 @@
node2 = createNode( "g:b:t:1" );
node3 = createNode( "g:c:t:1" );
}
-
+
// tests ------------------------------------------------------------------
-
+
public void testVisitSingleNode()
{
assertEmptyNodes();
@@ -86,17 +86,17 @@
}
// private methods --------------------------------------------------------
-
+
private void assertEmptyNodes()
{
- assertNodes( Collections.<DependencyNode>emptyList() );
+ assertNodes( Collections.<DependencyNode> emptyList() );
}
-
+
private void assertNodes( DependencyNode node )
{
assertNodes( Collections.singletonList( node ) );
}
-
+
private void assertNodes( List<DependencyNode> expectedNodes )
{
assertEquals( "Collected nodes", expectedNodes, visitor.getNodes() );
diff --git a/src/test/java/org/apache/maven/shared/dependency/tree/traversal/SerializingDependencyNodeVisitorTest.java b/src/test/java/org/apache/maven/shared/dependency/tree/traversal/SerializingDependencyNodeVisitorTest.java
index ade6228..4ad1173 100644
--- a/src/test/java/org/apache/maven/shared/dependency/tree/traversal/SerializingDependencyNodeVisitorTest.java
+++ b/src/test/java/org/apache/maven/shared/dependency/tree/traversal/SerializingDependencyNodeVisitorTest.java
@@ -65,47 +65,36 @@
assertTree( "g:p:t:1" + NEWLINE, rootNode );
}
-
+
public void testNodeWithChild()
{
DependencyNode rootNode = createNode( "g:p:t:1" );
rootNode.addChild( createNode( "g:a:t:1" ) );
- assertTree(
- "g:p:t:1" + NEWLINE +
- "\\- g:a:t:1" + NEWLINE,
- rootNode );
+ assertTree( "g:p:t:1" + NEWLINE + "\\- g:a:t:1" + NEWLINE, rootNode );
}
-
+
public void testNodeWithMultipleChildren()
{
DependencyNode rootNode = createNode( "g:p:t:1" );
rootNode.addChild( createNode( "g:a:t:1" ) );
rootNode.addChild( createNode( "g:b:t:1" ) );
rootNode.addChild( createNode( "g:c:t:1" ) );
-
- assertTree(
- "g:p:t:1" + NEWLINE +
- "+- g:a:t:1" + NEWLINE +
- "+- g:b:t:1" + NEWLINE +
- "\\- g:c:t:1" + NEWLINE,
- rootNode );
+
+ assertTree( "g:p:t:1" + NEWLINE + "+- g:a:t:1" + NEWLINE + "+- g:b:t:1" + NEWLINE + "\\- g:c:t:1" + NEWLINE,
+ rootNode );
}
-
+
public void testNodeWithGrandchild()
{
DependencyNode rootNode = createNode( "g:p:t:1" );
DependencyNode childNode = createNode( "g:a:t:1" );
rootNode.addChild( childNode );
childNode.addChild( createNode( "g:b:t:1" ) );
-
- assertTree(
- "g:p:t:1" + NEWLINE +
- "\\- g:a:t:1" + NEWLINE +
- " \\- g:b:t:1" + NEWLINE,
- rootNode );
+
+ assertTree( "g:p:t:1" + NEWLINE + "\\- g:a:t:1" + NEWLINE + " \\- g:b:t:1" + NEWLINE, rootNode );
}
-
+
public void testNodeWithMultipleGrandchildren()
{
DependencyNode rootNode = createNode( "g:p:t:1" );
@@ -115,16 +104,11 @@
DependencyNode child2Node = createNode( "g:c:t:1" );
rootNode.addChild( child2Node );
child2Node.addChild( createNode( "g:d:t:1" ) );
-
- assertTree(
- "g:p:t:1" + NEWLINE +
- "+- g:a:t:1" + NEWLINE +
- "| \\- g:b:t:1" + NEWLINE +
- "\\- g:c:t:1" + NEWLINE +
- " \\- g:d:t:1" + NEWLINE,
- rootNode );
+
+ assertTree( "g:p:t:1" + NEWLINE + "+- g:a:t:1" + NEWLINE + "| \\- g:b:t:1" + NEWLINE + "\\- g:c:t:1" + NEWLINE
+ + " \\- g:d:t:1" + NEWLINE, rootNode );
}
-
+
// private methods --------------------------------------------------------
private void assertTree( String expectedTree, DependencyNode actualNode )