Browse Source

[MRM-1292] replace the dependency graph by a maven-dependency-tree based implementation (maven-project is not used)


git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/MRM-1025@885812 13f79535-47bb-0310-9956-ffa450edef68
tags/archiva-1.4-M1
Brett Porter 14 years ago
parent
commit
52bcd1b58b
100 changed files with 1059 additions and 23946 deletions
  1. 0
    70
      archiva-modules/archiva-base/archiva-dependency-graph/pom.xml
  2. 0
    190
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/DependencyGraphFactory.java
  3. 0
    228
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/DependencyGraph.java
  4. 0
    50
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/DependencyGraphBuilder.java
  5. 0
    187
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/DependencyGraphEdge.java
  6. 0
    78
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/DependencyGraphKeys.java
  7. 0
    190
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/DependencyGraphNode.java
  8. 0
    267
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/DependencyGraphUtils.java
  9. 0
    56
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/DependencyResolutionEvent.java
  10. 0
    34
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/GraphListener.java
  11. 0
    78
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/GraphPhaseEvent.java
  12. 0
    43
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/GraphTask.java
  13. 0
    41
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/GraphTaskException.java
  14. 0
    30
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/PotentialCyclicEdgeProducer.java
  15. 0
    111
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/ProjectModelBasedGraphBuilder.java
  16. 0
    54
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/functors/EdgeCyclicPredicate.java
  17. 0
    47
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/functors/EdgeDisabledPredicate.java
  18. 0
    70
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/functors/EdgeExactScopePredicate.java
  19. 0
    53
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/functors/EdgeExcludedPredicate.java
  20. 0
    61
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/functors/EdgeFromPredicate.java
  21. 0
    48
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/functors/EdgeScopeClosure.java
  22. 0
    54
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/functors/EdgeToPredicate.java
  23. 0
    53
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/functors/EdgeWithinScopePredicate.java
  24. 0
    45
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/functors/NodeFromParentPredicate.java
  25. 0
    53
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/functors/NodeInEdgePredicate.java
  26. 0
    58
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/functors/NodePredicate.java
  27. 0
    55
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/functors/OrphanedNodePredicate.java
  28. 0
    43
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/functors/ToArtifactReferenceTransformer.java
  29. 0
    52
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/functors/UnresolvedGraphNodePredicate.java
  30. 0
    42
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/AbstractReduceEdgeVisitor.java
  31. 0
    210
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/DependencyManagementApplier.java
  32. 0
    146
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/DependencyManagementStack.java
  33. 0
    47
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/FlagCyclicEdgesTask.java
  34. 0
    69
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/FlagCyclicEdgesVisitor.java
  35. 0
    46
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/FlagExcludedEdgesTask.java
  36. 0
    81
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/FlagExcludedEdgesVisitor.java
  37. 0
    80
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/GraphCopier.java
  38. 0
    47
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/PopulateDependencyManagementTask.java
  39. 0
    86
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/PopulateGraphMasterTask.java
  40. 0
    48
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/ReduceEnabledEdgesTask.java
  41. 0
    41
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/ReduceEnabledEdgesVisitor.java
  42. 0
    63
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/ReduceScopeTask.java
  43. 0
    50
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/ReduceScopeVisitor.java
  44. 0
    47
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/ReduceTransitiveEdgesTask.java
  45. 0
    153
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/ReduceTransitiveEdgesVisitor.java
  46. 0
    89
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/RefineConflictsTask.java
  47. 0
    292
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/RefineConflictsVisitor.java
  48. 0
    108
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/ResolveGraphTask.java
  49. 0
    48
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/UpdateScopesTask.java
  50. 0
    81
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/UpdateScopesVisitor.java
  51. 0
    72
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/walk/BaseVisitor.java
  52. 0
    75
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/walk/DependencyGraphVisitor.java
  53. 0
    88
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/walk/DependencyGraphWalker.java
  54. 0
    148
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/walk/WalkBreadthFirstSearch.java
  55. 0
    140
      archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/walk/WalkDepthFirstSearch.java
  56. 0
    373
      archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/AbstractDependencyGraphFactoryTestCase.java
  57. 0
    172
      archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/AbstractMemoryRepository.java
  58. 0
    50
      archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/AllTests.java
  59. 0
    77
      archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/ArchivaCommonDependencyGraphTest.java
  60. 0
    3469
      archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/ArchivaCommonMemoryRepository.java
  61. 0
    200
      archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/ArchivaWebappDependencyGraphTest.java
  62. 0
    3469
      archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/ArchivaWebappMemoryRepository.java
  63. 0
    86
      archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/ArchivaXmlToolsDependencyGraphTest.java
  64. 0
    3469
      archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/ArchivaXmlToolsMemoryRepository.java
  65. 0
    98
      archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/ContinuumStoreDependencyGraphTest.java
  66. 0
    4142
      archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/ContinuumStoreMemoryRepository.java
  67. 0
    74
      archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/DepManDeepVersionDependencyGraphTest.java
  68. 0
    77
      archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/DepManDeepVersionMemoryRepository.java
  69. 0
    336
      archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/GraphvizDotTool.java
  70. 0
    135
      archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/MavenProjectInfoReportsPluginDependencyGraphTest.java
  71. 0
    1040
      archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/MavenProjectInfoReportsPluginMemoryRepository.java
  72. 0
    34
      archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/MemoryRepository.java
  73. 0
    95
      archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/MemoryRepositoryDependencyGraphBuilder.java
  74. 0
    70
      archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/SimpleDependencyGraphTest.java
  75. 0
    47
      archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/SimpleMemoryRepository.java
  76. 0
    104
      archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/WagonManagerDependencyGraphTest.java
  77. 0
    772
      archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/WagonManagerMemoryRepository.java
  78. 0
    66
      archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/functors/ToKeyTransformer.java
  79. 0
    225
      archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/tasks/DependencyManagementStackTest.java
  80. 0
    228
      archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/walk/DependencyGraphWalkerTest.java
  81. 0
    113
      archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/walk/WalkCollector.java
  82. 0
    1
      archiva-modules/archiva-base/pom.xml
  83. 0
    4
      archiva-modules/archiva-web/archiva-webapp/pom.xml
  84. 69
    121
      archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/DependencyTree.java
  85. 3
    3
      archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/DependencyTreeTag.java
  86. 64
    0
      archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/configuration/TestConfiguration.java
  87. 131
    0
      archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/tags/DependencyTreeTest.java
  88. 43
    0
      archiva-modules/archiva-web/archiva-webapp/src/test/repositories/test/groupId/artifactId/version/artifactId-version.pom
  89. 33
    0
      archiva-modules/archiva-web/archiva-webapp/src/test/repositories/test/groupId/child1/1.0/child1-1.0.pom
  90. 37
    0
      archiva-modules/archiva-web/archiva-webapp/src/test/repositories/test/groupId/child2/1.0/child2-1.0.pom
  91. 25
    0
      archiva-modules/archiva-web/archiva-webapp/src/test/repositories/test/groupId/child3/1.0/child3-1.0.pom
  92. 32
    0
      archiva-modules/archiva-web/archiva-webapp/src/test/repositories/test/groupId/grandchild1/2.0/grandchild1-2.0.pom
  93. 25
    0
      archiva-modules/archiva-web/archiva-webapp/src/test/repositories/test/groupId/grandchild2/2.0/grandchild2-2.0.pom
  94. 25
    0
      archiva-modules/archiva-web/archiva-webapp/src/test/repositories/test/groupId/grandchild3/2.0/grandchild3-2.0.pom
  95. 26
    0
      archiva-modules/archiva-web/archiva-webapp/src/test/repositories/test/groupId/great-grandchild/3.0/great-grandchild-3.0.pom
  96. 39
    0
      archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/tags/DependencyTreeTest.xml
  97. 15
    0
      archiva-modules/plugins/maven2-repository/pom.xml
  98. 445
    0
      archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/DefaultDependencyTreeBuilder.java
  99. 47
    0
      archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/DependencyTreeBuilder.java
  100. 0
    0
      archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/dependency/tree/maven2/DependencyTreeBuilderTest.java

+ 0
- 70
archiva-modules/archiva-base/archiva-dependency-graph/pom.xml View File

@@ -1,70 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-base</artifactId>
<version>1.3-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>archiva-dependency-graph</artifactId>
<name>Archiva Base :: Dependency Graph</name>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-spring</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-model</artifactId>
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-repository-layer</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-metadata</artifactId>
<executions>
<execution>
<id>descriptor</id>
<goals>
<goal>generate-metadata</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

+ 0
- 190
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/DependencyGraphFactory.java View File

@@ -1,190 +0,0 @@
package org.apache.maven.archiva.dependency;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import java.util.ArrayList;
import java.util.List;

import org.apache.maven.archiva.dependency.graph.DependencyGraph;
import org.apache.maven.archiva.dependency.graph.DependencyGraphBuilder;
import org.apache.maven.archiva.dependency.graph.GraphListener;
import org.apache.maven.archiva.dependency.graph.GraphPhaseEvent;
import org.apache.maven.archiva.dependency.graph.GraphTask;
import org.apache.maven.archiva.dependency.graph.GraphTaskException;
import org.apache.maven.archiva.dependency.graph.PotentialCyclicEdgeProducer;
import org.apache.maven.archiva.dependency.graph.tasks.FlagCyclicEdgesTask;
import org.apache.maven.archiva.dependency.graph.tasks.FlagExcludedEdgesTask;
import org.apache.maven.archiva.dependency.graph.tasks.PopulateGraphMasterTask;
import org.apache.maven.archiva.dependency.graph.tasks.ReduceEnabledEdgesTask;
import org.apache.maven.archiva.dependency.graph.tasks.ReduceScopeTask;
import org.apache.maven.archiva.dependency.graph.tasks.ReduceTransitiveEdgesTask;
import org.apache.maven.archiva.dependency.graph.tasks.RefineConflictsTask;
import org.apache.maven.archiva.dependency.graph.tasks.UpdateScopesTask;
import org.apache.maven.archiva.model.DependencyScope;
import org.apache.maven.archiva.model.VersionedReference;

/**
* DependencyGraphFactory
*
* @version $Id$
*/
public class DependencyGraphFactory
{
private GraphTask taskFlagCyclicEdges;

private PopulateGraphMasterTask taskPopulateGraph;

private ReduceScopeTask taskReduceScope;

private List<GraphListener> listeners;

private DependencyGraphBuilder graphBuilder;

private List<GraphTask> tasks;

public DependencyGraphFactory()
{
listeners = new ArrayList<GraphListener>();

taskFlagCyclicEdges = new FlagCyclicEdgesTask();
taskPopulateGraph = new PopulateGraphMasterTask();
taskReduceScope = new ReduceScopeTask( DependencyScope.TEST );

tasks = new ArrayList<GraphTask>();

/* Take the basic graph, and expand the nodes fully, including depman.
*/
tasks.add( taskPopulateGraph );

/* Identify, flag, and disable excluded edges.
*/
tasks.add( new FlagExcludedEdgesTask() );

/* Reduce the edges of the graph to only those that are enabled.
*/
tasks.add( new ReduceEnabledEdgesTask() );

/* Identify dependencies that conflict, resolve to single node.
*
* This will ...
* 1) filter the distant conflicts away for the nearer ones.
* 2) same distance nodes will pick 'newest' version.
*
* This can cause a collapsing of node versions.
*/
tasks.add( new RefineConflictsTask() );

/* Reduce the scope of the graph to those visible by the 'test' scope.
*/
tasks.add( taskReduceScope );

/* Reduce the edges of the graph. Use the transitive reduction algorithm
* to remove redundant edges.
*/
tasks.add( new ReduceTransitiveEdgesTask() );

/* Update the scopes of the edges to conform to the parent setting.
*/
tasks.add( new UpdateScopesTask() );
}

public void addGraphListener( GraphListener listener )
{
this.listeners.add( listener );
}

/**
* Get the Graph for a specific Versioned Project Reference.
*
* @param versionedProjectReference
* @return
*/
public DependencyGraph getGraph( VersionedReference versionedProjectReference )
throws GraphTaskException
{
DependencyGraph graph = graphBuilder.createGraph( versionedProjectReference );

triggerGraphPhase( GraphPhaseEvent.GRAPH_NEW, null, graph );

for ( GraphTask task : this.tasks )
{
try
{
triggerGraphPhase( GraphPhaseEvent.GRAPH_TASK_PRE, task, graph );
task.executeTask( graph );
if ( task instanceof PotentialCyclicEdgeProducer )
{
taskFlagCyclicEdges.executeTask( graph );
}
triggerGraphPhase( GraphPhaseEvent.GRAPH_TASK_POST, task, graph );
}
catch ( GraphTaskException e )
{
triggerGraphError( e, graph );
throw e;
}
catch ( Exception e )
{
GraphTaskException gte = new GraphTaskException( e.getMessage(), e );
triggerGraphError( gte, graph );
throw gte;
}
}

triggerGraphPhase( GraphPhaseEvent.GRAPH_DONE, null, graph );

return graph;
}

public void removeGraphListener( GraphListener listener )
{
this.listeners.remove( listener );
}

public void setDesiredScope( String scope )
{
taskReduceScope.setScope( scope );
}

public void setGraphBuilder( DependencyGraphBuilder graphBuilder )
{
this.graphBuilder = graphBuilder;
taskPopulateGraph.setBuilder( graphBuilder );
}

private void triggerGraphError( GraphTaskException e, DependencyGraph graph )
{
for ( GraphListener listener : listeners )
{
listener.graphError( e, graph );
}
}

private void triggerGraphPhase( int type, GraphTask task, DependencyGraph graph )
{
GraphPhaseEvent evt = new GraphPhaseEvent( type, task, graph );

for ( GraphListener listener : listeners )
{
listener.graphPhaseEvent( evt );
}
}

}

+ 0
- 228
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/DependencyGraph.java View File

@@ -1,228 +0,0 @@
package org.apache.maven.archiva.dependency.graph;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.map.ListOrderedMap;
import org.apache.maven.archiva.dependency.graph.functors.EdgeFromPredicate;
import org.apache.maven.archiva.dependency.graph.functors.EdgeToPredicate;
import org.apache.maven.archiva.model.ArtifactReference;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
* DependencyGraph
*
* @version $Id$
*/
public class DependencyGraph
{
public static final int DISABLED_CYCLIC = 0;

public static final int DISABLED_EXCLUDED = 1;

public static final int DISABLED_OPTIONAL = 2;

public static final int DISABLED_NEARER_DEP = 3;

public static final int DISABLED_NEARER_EDGE = 4;

private DependencyGraphNode rootNode;

private Set<DependencyGraphEdge> edges = new HashSet<DependencyGraphEdge>();

private ListOrderedMap nodes = new ListOrderedMap();

public DependencyGraph( String groupId, String artifactId, String version )
{
ArtifactReference rootRef = new ArtifactReference();
rootRef.setGroupId( groupId );
rootRef.setArtifactId( artifactId );
rootRef.setVersion( version );
rootRef.setClassifier( "" );
rootRef.setType( "pom" );

this.rootNode = new DependencyGraphNode( rootRef );
}

public DependencyGraph( DependencyGraphNode root )
{
this.rootNode = root;
}

public Collection<DependencyGraphEdge> getEdges()
{
return edges;
}

@SuppressWarnings("unchecked")
public Collection<DependencyGraphNode> getNodes()
{
return nodes.values();
}

public DependencyGraphNode getRootNode()
{
return rootNode;
}

public void setRootNode( DependencyGraphNode rootNode )
{
this.rootNode = rootNode;
}

/**
* Add the edge to the {@link DependencyGraph}.
*
* @param edge the edge to add.
*/
public void addEdge( final DependencyGraphEdge edge )
{
if ( edge.getNodeFrom() == null )
{
throw new IllegalArgumentException( "edge.nodeFrom cannot be null." );
}

if ( edge.getNodeTo() == null )
{
throw new IllegalArgumentException( "edge.nodeTo cannot be null." );
}

this.edges.add( edge );
}

public DependencyGraphNode addNode( DependencyGraphNode node )
{
if ( node == null )
{
throw new IllegalArgumentException( "Unable to add a null node." );
}

if ( node.getArtifact() == null )
{
throw new IllegalArgumentException( "Unable to add a node with a null artifact reference." );
}

int prevNodeIdx = this.nodes.indexOf( node );

// Found it in the node tree?
if ( prevNodeIdx >= 0 )
{
// Merge new node into existing node.
DependencyGraphNode previousNode = (DependencyGraphNode) this.nodes.get( prevNodeIdx );

if ( CollectionUtils.isNotEmpty( node.getExcludes() ) )
{
previousNode.getExcludes().addAll( node.getExcludes() );
}

if ( CollectionUtils.isNotEmpty( node.getDependencyManagement() ) )
{
previousNode.getDependencyManagement().addAll( node.getDependencyManagement() );
}

if ( node.isFromParent() )
{
previousNode.setFromParent( true );
}

// Return newly merged node (from existing node)
return previousNode;
}

// This is a new node, didn't exist before, just save it.
this.nodes.put( node.getArtifact(), node );

return node;
}

public boolean hasNode( DependencyGraphNode node )
{
return this.nodes.containsKey( node.getArtifact() );
}

public boolean hasEdge( DependencyGraphEdge edge )
{
return this.edges.contains( edge );
}

/**
* Get the list of edges from the provided node.
*
* @param node the node to use as the 'from' side of an edge.
* @return the edges from the provided node.
*/
public List<DependencyGraphEdge> getEdgesFrom( DependencyGraphNode node )
{
List<DependencyGraphEdge> ret = new ArrayList<DependencyGraphEdge>();
CollectionUtils.select( this.edges, new EdgeFromPredicate( node.getArtifact() ), ret );
return ret;
}

/**
* Get the list of edges to the provided node.
*
* @param node the node to use as the 'to' side of an edge.
* @return the edges to the provided node.
*/
public List<DependencyGraphEdge> getEdgesTo( DependencyGraphNode node )
{
List<DependencyGraphEdge> ret = new ArrayList<DependencyGraphEdge>();
CollectionUtils.select( this.edges, new EdgeToPredicate( node.getArtifact() ), ret );
return ret;
}

/**
* Get the node for the specified artifact reference.
*
* @param ref the artifact reference to use to find the node.
* @return the node that was found. (null if not found)
*/
public DependencyGraphNode getNode( ArtifactReference ref )
{
return (DependencyGraphNode) this.nodes.get( ref );
}

public void removeEdge( DependencyGraphEdge edge )
{
this.edges.remove( edge );
}

public void removeNode( DependencyGraphNode node )
{
List<DependencyGraphEdge> edges = getEdgesFrom( node );
if ( !edges.isEmpty() )
{
System.out.println( "Removing node left <" + edges + "> hanging <from> edges." );
}

edges = getEdgesTo( node );
if ( !edges.isEmpty() )
{
System.out.println( "Removing node left <" + edges + "> hanging <to> edges." );
}

this.nodes.remove( node.getArtifact() );
}
}

+ 0
- 50
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/DependencyGraphBuilder.java View File

@@ -1,50 +0,0 @@
package org.apache.maven.archiva.dependency.graph;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.maven.archiva.model.VersionedReference;

/**
* DependencyGraphBuilder
*
* @version $Id$
*/
public interface DependencyGraphBuilder
{
/**
* Given a node and a versioned project rexpandeference, resolve the details of the node, creating
* any dependencies and edges as needed.
*
* @param graph the graph to add nodes and edges to.
* @param node the node where the resolution should occur.
* @param versionedProjectReference the versioned project reference for the node
* that needs to be resolved.
*/
public void resolveNode( DependencyGraph graph, DependencyGraphNode node,
VersionedReference versionedProjectReference );

/**
* Create a new graph, with the root of the graph for the node specified.
*
* @param versionedProjectReference the root node for the graph.
* @return the new DependencyGraph, complete with root node and direct dependencies.
*/
public DependencyGraph createGraph( VersionedReference versionedProjectReference );
}

+ 0
- 187
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/DependencyGraphEdge.java View File

@@ -1,187 +0,0 @@
package org.apache.maven.archiva.dependency.graph;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.maven.archiva.model.ArtifactReference;
import org.apache.maven.archiva.model.DependencyScope;

/**
* DependencyGraphEdge
*
* @version $Id$
*/
public class DependencyGraphEdge
{
private ArtifactReference nodeFrom;

private ArtifactReference nodeTo;

private String scope;
private boolean disabled = false;

private int disabledType;

private String disabledReason;

public DependencyGraphEdge( ArtifactReference fromNode, ArtifactReference toNode )
{
super();
this.nodeFrom = fromNode;
this.nodeTo = toNode;
this.scope = DependencyScope.COMPILE;
}

public boolean equals( Object obj )
{
if ( this == obj )
{
return true;
}
if ( obj == null )
{
return false;
}
if ( getClass() != obj.getClass() )
{
return false;
}
final DependencyGraphEdge other = (DependencyGraphEdge) obj;
if ( nodeFrom == null )
{
if ( other.nodeFrom != null )
{
return false;
}
}
else if ( !nodeFrom.equals( other.nodeFrom ) )
{
return false;
}
if ( nodeTo == null )
{
if ( other.nodeTo != null )
{
return false;
}
}
else if ( !nodeTo.equals( other.nodeTo ) )
{
return false;
}
return true;
}

public String getDisabledReason()
{
return disabledReason;
}

public int getDisabledType()
{
return disabledType;
}

public ArtifactReference getNodeFrom()
{
return nodeFrom;
}

public ArtifactReference getNodeTo()
{
return nodeTo;
}

public String getScope()
{
return scope;
}

public int hashCode()
{
final int PRIME = 31;
int result = 1;
result = PRIME * result + ( ( nodeFrom == null ) ? 0 : nodeFrom.hashCode() );
result = PRIME * result + ( ( nodeTo == null ) ? 0 : nodeTo.hashCode() );
return result;
}

public boolean isDisabled()
{
return disabled;
}

public void setDisabled( boolean disabled )
{
this.disabled = disabled;
if( this.disabled == false )
{
this.disabledReason = null;
this.disabledType = -1;
}
}

public void setDisabledReason( String disabledReason )
{
this.disabledReason = disabledReason;
}

public void setDisabledType( int disabledType )
{
this.disabledType = disabledType;
}
public void setNodeFrom( ArtifactReference ref )
{
this.nodeFrom = ref;
}

public void setNodeFrom( DependencyGraphNode node )
{
this.nodeFrom = node.getArtifact();
}
public void setNodeTo( ArtifactReference ref )
{
this.nodeTo = ref;
}

public void setNodeTo( DependencyGraphNode node )
{
this.nodeTo = node.getArtifact();
}

public void setScope( String scope )
{
this.scope = scope;
}

public String toString()
{
StringBuffer sb = new StringBuffer();

sb.append( "GraphEdge[" );
sb.append( "from=" ).append( DependencyGraphKeys.toKey( nodeFrom ) );
sb.append( ",to=" ).append( DependencyGraphKeys.toKey( nodeTo ) );
sb.append( "]" );

return sb.toString();
}
}

+ 0
- 78
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/DependencyGraphKeys.java View File

@@ -1,78 +0,0 @@
package org.apache.maven.archiva.dependency.graph;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.commons.lang.StringUtils;
import org.apache.maven.archiva.model.ArtifactReference;
import org.apache.maven.archiva.model.Dependency;
import org.apache.maven.archiva.model.Exclusion;

/**
* Key generation for the various objects used within the DependencyGraph.
*
* @version $Id$
*/
public class DependencyGraphKeys
{
public static String toManagementKey( DependencyGraphNode node )
{
return toManagementKey( node.getArtifact() );
}

public static String toManagementKey( ArtifactReference ref )
{
StringBuffer key = new StringBuffer();
key.append( ref.getGroupId() ).append( ":" );
key.append( ref.getArtifactId() );
return key.toString();
}

public static String toManagementKey( Dependency ref )
{
StringBuffer key = new StringBuffer();
key.append( ref.getGroupId() ).append( ":" );
key.append( ref.getArtifactId() );
return key.toString();
}

public static String toManagementKey( Exclusion ref )
{
StringBuffer key = new StringBuffer();
key.append( ref.getGroupId() ).append( ":" );
key.append( ref.getArtifactId() );
return key.toString();
}

public static String toKey( DependencyGraphNode node )
{
return toKey( node.getArtifact() );
}

public static String toKey( ArtifactReference ref )
{
StringBuffer key = new StringBuffer();
key.append( ref.getGroupId() ).append( ":" );
key.append( ref.getArtifactId() ).append( ":" );
key.append( ref.getVersion() ).append( ":" );
key.append( StringUtils.defaultString( ref.getClassifier() ) ).append( ":" );
key.append( ref.getType() );
return key.toString();
}
}

+ 0
- 190
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/DependencyGraphNode.java View File

@@ -1,190 +0,0 @@
package org.apache.maven.archiva.dependency.graph;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.maven.archiva.model.ArtifactReference;
import org.apache.maven.archiva.model.Dependency;
import org.apache.maven.archiva.model.Exclusion;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
* DependencyGraphNode
*
* @version $Id$
*/
public class DependencyGraphNode
{
/**
* The artifact reference for this node.
*/
private ArtifactReference artifact;

/**
* The project level dependency management section for this artifact.
*/
private List<Dependency> dependencyManagement = new ArrayList<Dependency>();

/**
* The list of excluded groupId:artifactId for this node's sub-nodes.
*/
private Set<String> excludes = new HashSet<String>();

/**
* Flag indicating that this node has been resolved from disk.
* Initially this is set to false, when the node is added due to a dependency entry in the
* project's pom.
* When the resolver comes through and reads the model for this node, it sets this to true.
*/
private boolean resolved = false;
/**
* Flag indicating that this dependency exists because of a parent dependency.
* TODO: move this to DependencyGraphEdge (where it really belongs)
*/
private boolean fromParent = false;

/**
* Booleaning indicating that this node is in conflict with another node in the graph.
* If this is true, that means this node is flagged for removal.
*/
private boolean conflicted = false;

public DependencyGraphNode( ArtifactReference artifact )
{
super();
this.artifact = artifact;
}

public void addExclude( Exclusion exclusion )
{
this.excludes.add( DependencyGraphKeys.toManagementKey( exclusion ) );
}

public boolean equals( Object obj )
{
if ( this == obj )
{
return true;
}
if ( obj == null )
{
return false;
}
if ( getClass() != obj.getClass() )
{
return false;
}
final DependencyGraphNode other = (DependencyGraphNode) obj;
if ( artifact == null )
{
if ( other.artifact != null )
{
return false;
}
}
else if ( !artifact.equals( other.artifact ) )
{
return false;
}
return true;
}

public ArtifactReference getArtifact()
{
return artifact;
}

public List<Dependency> getDependencyManagement()
{
return dependencyManagement;
}

public Set<String> getExcludes()
{
return excludes;
}

public int hashCode()
{
final int PRIME = 31;
int result = 1;
result = PRIME * result + ( ( artifact == null ) ? 0 : artifact.hashCode() );
return result;
}

public boolean isConflicted()
{
return conflicted;
}

public boolean isResolved()
{
return resolved;
}

public void addDependencyManagement( Dependency dep )
{
this.dependencyManagement.add( dep );
}

public void setArtifact( ArtifactReference artifact )
{
this.artifact = artifact;
}

public void setConflicted( boolean conflicted )
{
this.conflicted = conflicted;
}

public void setDependencyManagement( List<Dependency> dependencyManagement )
{
this.dependencyManagement = dependencyManagement;
}

public void setExcludes( Set<String> excludes )
{
this.excludes = excludes;
}

public void setResolved( boolean resolved )
{
this.resolved = resolved;
}

public String toString()
{
return DependencyGraphKeys.toKey( artifact );
}

public boolean isFromParent()
{
return fromParent;
}

public void setFromParent( boolean fromParent )
{
this.fromParent = fromParent;
}
}

+ 0
- 267
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/DependencyGraphUtils.java View File

@@ -1,267 +0,0 @@
package org.apache.maven.archiva.dependency.graph;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.Predicate;
import org.apache.commons.collections.functors.AndPredicate;
import org.apache.commons.collections.functors.NotPredicate;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.archiva.dependency.graph.functors.NodePredicate;
import org.apache.maven.archiva.dependency.graph.functors.OrphanedNodePredicate;
import org.apache.maven.archiva.model.ArchivaProjectModel;
import org.apache.maven.archiva.model.ArtifactReference;
import org.apache.maven.archiva.model.Dependency;
import org.apache.maven.archiva.model.DependencyScope;
import org.apache.maven.archiva.model.Exclusion;
import org.apache.maven.archiva.model.VersionedReference;

/**
* Utilities for manipulating the DependencyGraph.
*
* @version $Id$
*/
public class DependencyGraphUtils
{
/**
* Standard way to add a model to the graph.
*
* NOTE: Used by archiva-repository-layer runtime and archiva-dependency-graph tests.
*
* @param model the model to add
* @param graph the graph to add it to
* @param fromNode the node to add it from.
*/
public static void addNodeFromModel( ArchivaProjectModel model, DependencyGraph graph, DependencyGraphNode fromNode )
{
if ( model == null )
{
throw new IllegalStateException( "Unable to add null model for "
+ DependencyGraphKeys.toKey( fromNode.getArtifact() ) );
}

if ( model.getRelocation() != null )
{
// We need to CHANGE this node.
ArtifactReference refTO = new ArtifactReference();

refTO.setGroupId( fromNode.getArtifact().getGroupId() );
refTO.setArtifactId( fromNode.getArtifact().getArtifactId() );
refTO.setVersion( fromNode.getArtifact().getVersion() );
refTO.setClassifier( fromNode.getArtifact().getClassifier() );
refTO.setType( fromNode.getArtifact().getType() );

VersionedReference relocation = model.getRelocation();

if ( StringUtils.isNotBlank( relocation.getGroupId() ) )
{
refTO.setGroupId( relocation.getGroupId() );
}

if ( StringUtils.isNotBlank( relocation.getArtifactId() ) )
{
refTO.setArtifactId( relocation.getArtifactId() );
}

if ( StringUtils.isNotBlank( relocation.getVersion() ) )
{
refTO.setVersion( relocation.getVersion() );
}

DependencyGraphNode nodeTO = new DependencyGraphNode( refTO );

graph.addNode( nodeTO );
collapseNodes( graph, fromNode, nodeTO );
return;
}

boolean isRootNode = graph.getRootNode().equals( fromNode );

if ( CollectionUtils.isNotEmpty( model.getDependencyManagement() ) )
{
for ( Dependency dependency : model.getDependencyManagement() )
{
fromNode.addDependencyManagement( dependency );
}
}

if ( CollectionUtils.isNotEmpty( model.getDependencies() ) )
{
for ( Dependency dependency : model.getDependencies() )
{
String scope = dependency.getScope();

// Test scopes *NOT* from root node can be skipped.
if ( DependencyScope.TEST.equals( scope ) && !isRootNode )
{
// skip add of test scope
continue;
}

ArtifactReference artifactRef = new ArtifactReference();
artifactRef.setGroupId( dependency.getGroupId() );
artifactRef.setArtifactId( dependency.getArtifactId() );
artifactRef.setVersion( dependency.getVersion() );
artifactRef.setClassifier( dependency.getClassifier() );
artifactRef.setType( dependency.getType() );

DependencyGraphNode toNode = new DependencyGraphNode( artifactRef );

if ( CollectionUtils.isNotEmpty( dependency.getExclusions() ) )
{
for ( Exclusion exclusion : dependency.getExclusions() )
{
toNode.addExclude( exclusion );
}
}

if ( dependency.isFromParent() )
{
toNode.setFromParent( true );
}

// Add node (to)
graph.addNode( toNode );

DependencyGraphEdge edge = new DependencyGraphEdge( fromNode.getArtifact(), toNode.getArtifact() );
edge.setScope( StringUtils.defaultIfEmpty( dependency.getScope(), DependencyScope.COMPILE ) );

if ( dependency.isOptional() )
{
edge.setDisabled( true );
edge.setDisabledType( DependencyGraph.DISABLED_OPTIONAL );
edge.setDisabledReason( "Optional Dependency" );
}

graph.addEdge( edge );
}
}

fromNode.setResolved( true );
graph.addNode( fromNode );
}

/**
* Clean out any nodes that may have become orphaned in the graph.
*
* @param graph the graph to check.
*/
public static void cleanupOrphanedNodes( DependencyGraph graph )
{
boolean done = false;

Predicate orphanedNodePredicate = new OrphanedNodePredicate( graph );
Predicate notRootNode = NotPredicate.getInstance( new NodePredicate( graph.getRootNode().getArtifact() ) );
Predicate orphanedChildNodePredicate = AndPredicate.getInstance( notRootNode, orphanedNodePredicate );

while ( !done )
{
// Find orphaned node.
DependencyGraphNode orphanedNode = (DependencyGraphNode) CollectionUtils.find( graph.getNodes(),
orphanedChildNodePredicate );

if ( orphanedNode == null )
{
done = true;
break;
}

// Remove edges FROM orphaned node.
for ( DependencyGraphEdge edge : graph.getEdgesFrom( orphanedNode ) )
{
graph.removeEdge( edge );
}

// Remove orphaned node.
graph.removeNode( orphanedNode );
}
}

/**
* Functionaly similar to {@link #collapseVersions(DependencyGraph, ArtifactReference, String, String)}, but
* in a new, easier to use, format.
*
* 1) Removes the FROM edges connected to the FROM node
* 2) Moves the TO edges connected to the FROM node to the TO node.
* 3) Removes the FROM node (which is now orphaned)
*
* @param graph the graph to perform operation on
* @param nodeFrom the node to collapse from
* @param nodeTo the node to collapse to
*/
public static void collapseNodes( DependencyGraph graph, DependencyGraphNode nodeFROM, DependencyGraphNode nodeTO )
{
Set<DependencyGraphEdge> edgesToRemove = new HashSet<DependencyGraphEdge>();

// 1) Remove all of the edge.from references from nodeFROM
List<DependencyGraphEdge> fromEdges = graph.getEdgesFrom( nodeFROM );
if ( CollectionUtils.isNotEmpty( fromEdges ) )
{
edgesToRemove.addAll( fromEdges );
}

// 2) Swing all of the edge.to references from nodeFROM to nodeTO.
// System.out.println( "Swinging incoming edges from " + nodeFROM );
// System.out.println( " to " + nodeTO );
List<DependencyGraphEdge> toEdges = graph.getEdgesTo( nodeFROM );
for ( DependencyGraphEdge edge : toEdges )
{
// Identify old edge to remove.
edgesToRemove.add( edge );

// Clone edge, set edge.to and add to graph.
DependencyGraphEdge newedge = clone( edge );
newedge.setNodeTo( nodeTO );
// System.out.println( " edge from: " + edge );
// System.out.println( " to: " + newedge );
graph.addEdge( newedge );
}

// Actually remove the old edges.
for ( DependencyGraphEdge edge : edgesToRemove )
{
graph.removeEdge( edge );
}

// 3) Remove the nodeFROM
graph.removeNode( nodeFROM );
}

/**
* Create a clone of an edge.
*
* @param edge the edge to clone.
* @return the cloned edge.
*/
public static DependencyGraphEdge clone( DependencyGraphEdge edge )
{
DependencyGraphEdge cloned = new DependencyGraphEdge( edge.getNodeFrom(), edge.getNodeTo() );
cloned.setDisabled( edge.isDisabled() );
cloned.setDisabledReason( edge.getDisabledReason() );
cloned.setDisabledType( edge.getDisabledType() );
cloned.setScope( edge.getScope() );

return cloned;
}
}

+ 0
- 56
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/DependencyResolutionEvent.java View File

@@ -1,56 +0,0 @@
package org.apache.maven.archiva.dependency.graph;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

/**
* DependencyResolutionEvent
*
* @version $Id$
*/
public class DependencyResolutionEvent
{
public static final int ADDING_MODEL = 1;

public static final int DEP_CONFLICT_OMIT_FOR_NEARER = 2;

public static final int CYCLE_BROKEN = 3;

public static final int APPLYING_DEPENDENCY_MANAGEMENT = 4;

private int type;

private DependencyGraph graph;

public DependencyResolutionEvent( int type, DependencyGraph graph )
{
this.type = type;
this.graph = graph;
}

public DependencyGraph getGraph()
{
return graph;
}

public int getType()
{
return type;
}
}

+ 0
- 34
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/GraphListener.java View File

@@ -1,34 +0,0 @@
package org.apache.maven.archiva.dependency.graph;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

/**
* GraphListener
*
* @version $Id$
*/
public interface GraphListener
{
public void graphError( GraphTaskException e, DependencyGraph currentGraph );

public void graphPhaseEvent( GraphPhaseEvent event );

public void dependencyResolutionEvent( DependencyResolutionEvent event );
}

+ 0
- 78
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/GraphPhaseEvent.java View File

@@ -1,78 +0,0 @@
package org.apache.maven.archiva.dependency.graph;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

/**
* GraphPhaseEvent
*
* @version $Id$
*/
public class GraphPhaseEvent
{
/**
* Graph Phase Event Type - New Graph has been created. No tasks have been run yet.
* NOTE: {{@link #getTask()} will be null for this type.
*/
public static final int GRAPH_NEW = 0;

/**
* Graph Phase Event Type - Graph Task is about to run.
*/
public static final int GRAPH_TASK_PRE = 1;

/**
* Graph Phase Event Type - Graph Task has finished.
*/
public static final int GRAPH_TASK_POST = 2;

/**
* Graph Phase Event Type - All Graph Tasks are done.
* NOTE: {{@link #getTask()} will be null for this type.
*/
public static final int GRAPH_DONE = 10;

private int type;
private GraphTask task;

private DependencyGraph graph;

public GraphPhaseEvent( int type, GraphTask task, DependencyGraph graph )
{
this.type = type;
this.task = task;
this.graph = graph;
}

public DependencyGraph getGraph()
{
return graph;
}

public GraphTask getTask()
{
return task;
}

public int getType()
{
return type;
}
}

+ 0
- 43
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/GraphTask.java View File

@@ -1,43 +0,0 @@
package org.apache.maven.archiva.dependency.graph;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

/**
* A Graph Task.
*
* @version $Id$
*/
public interface GraphTask
{
/**
* Get the id for this task.
*
* @return the id for this task. (used in Exception messages and {@link GraphPhaseEvent})
*/
public String getTaskId();

/**
* Execute the Graph Task.
*
* @param graph the graph to execute the task on.
*/
public void executeTask( DependencyGraph graph )
throws GraphTaskException;
}

+ 0
- 41
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/GraphTaskException.java View File

@@ -1,41 +0,0 @@
package org.apache.maven.archiva.dependency.graph;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.maven.archiva.common.ArchivaException;

/**
* GraphTaskException
*
* @version $Id$
*/
public class GraphTaskException
extends ArchivaException
{
public GraphTaskException( String message, Throwable cause )
{
super( message, cause );
}

public GraphTaskException( String message )
{
super( message );
}
}

+ 0
- 30
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/PotentialCyclicEdgeProducer.java View File

@@ -1,30 +0,0 @@
package org.apache.maven.archiva.dependency.graph;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

/**
* A tag for a {@link GraphTask} that has the potential to produce a cyclic edge.
*
* @version $Id$
*/
public interface PotentialCyclicEdgeProducer
{
/* no interface, just a tag */
}

+ 0
- 111
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/ProjectModelBasedGraphBuilder.java View File

@@ -1,111 +0,0 @@
package org.apache.maven.archiva.dependency.graph;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.maven.archiva.model.ArchivaProjectModel;
import org.apache.maven.archiva.model.ArtifactReference;
import org.apache.maven.archiva.model.VersionedReference;
import org.apache.maven.archiva.repository.project.ProjectModelException;
import org.apache.maven.archiva.repository.project.ProjectModelResolverFactory;
import org.apache.maven.archiva.repository.project.filters.EffectiveProjectModelFilter;

/**
* ProjectModelBasedGraphBuilder
*
* @version $Id$
*
* @plexus.component
* role="org.apache.maven.archiva.dependency.graph.DependencyGraphBuilder"
* role-hint="project-model"
*/
public class ProjectModelBasedGraphBuilder
implements DependencyGraphBuilder
{
/**
* @plexus.requirement
*/
private ProjectModelResolverFactory resolverFactory;

/**
* @plexus.requirement
* role="org.apache.maven.archiva.repository.project.ProjectModelFilter"
* role-hint="effective"
*/
private EffectiveProjectModelFilter effectiveFilter = new EffectiveProjectModelFilter();

public DependencyGraph createGraph( VersionedReference versionedProjectReference )
{
String groupId = versionedProjectReference.getGroupId();
String artifactId = versionedProjectReference.getArtifactId();
String version = versionedProjectReference.getVersion();

DependencyGraph graph = new DependencyGraph( groupId, artifactId, version );
return graph;
}

public void resolveNode( DependencyGraph graph, DependencyGraphNode fromNode,
VersionedReference versionedProjectReference )
{
ArchivaProjectModel model = resolveModel( fromNode.getArtifact() );

DependencyGraphUtils.addNodeFromModel( model, graph, fromNode );
}

private ArchivaProjectModel resolveModel( ArtifactReference reference )
{
VersionedReference projectRef = new VersionedReference();

projectRef.setGroupId( reference.getGroupId() );
projectRef.setArtifactId( reference.getArtifactId() );
projectRef.setVersion( reference.getVersion() );

ArchivaProjectModel model = resolverFactory.getCurrentResolverStack().findProject( projectRef );

if ( model == null )
{
return createDefaultModel( reference );
}

try
{
ArchivaProjectModel processedModel = effectiveFilter.filter( model );

return processedModel;
}
catch ( ProjectModelException e )
{
e.printStackTrace( System.err );
return createDefaultModel( reference );
}
}

private ArchivaProjectModel createDefaultModel( ArtifactReference reference )
{
ArchivaProjectModel model = new ArchivaProjectModel();

// Create default (dummy) model
model = new ArchivaProjectModel();
model.setGroupId( reference.getGroupId() );
model.setArtifactId( reference.getArtifactId() );
model.setVersion( reference.getVersion() );
model.setPackaging( reference.getType() );
return model;
}
}

+ 0
- 54
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/functors/EdgeCyclicPredicate.java View File

@@ -1,54 +0,0 @@
package org.apache.maven.archiva.dependency.graph.functors;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.commons.collections.Predicate;
import org.apache.maven.archiva.dependency.graph.DependencyGraph;
import org.apache.maven.archiva.dependency.graph.DependencyGraphEdge;

/**
* EdgeCyclicPredicate
*
* @version $Id$
*/
public class EdgeCyclicPredicate
implements Predicate
{
private static Predicate INSTANCE = new EdgeCyclicPredicate();

public static Predicate getInstance()
{
return INSTANCE;
}

public boolean evaluate( Object object )
{
boolean satisfies = false;

if ( object instanceof DependencyGraphEdge )
{
DependencyGraphEdge edge = (DependencyGraphEdge) object;
satisfies = ( edge.isDisabled() && ( edge.getDisabledType() == DependencyGraph.DISABLED_CYCLIC ) );
}

return satisfies;
}

}

+ 0
- 47
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/functors/EdgeDisabledPredicate.java View File

@@ -1,47 +0,0 @@
package org.apache.maven.archiva.dependency.graph.functors;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.commons.collections.Predicate;
import org.apache.maven.archiva.dependency.graph.DependencyGraphEdge;

/**
* EdgeDisabledPredicate
*
* @version $Id$
*/
public class EdgeDisabledPredicate
implements Predicate
{

public boolean evaluate( Object object )
{
boolean satisfies = false;

if ( object instanceof DependencyGraphEdge )
{
DependencyGraphEdge edge = (DependencyGraphEdge) object;
satisfies = edge.isDisabled();
}

return satisfies;
}

}

+ 0
- 70
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/functors/EdgeExactScopePredicate.java View File

@@ -1,70 +0,0 @@
package org.apache.maven.archiva.dependency.graph.functors;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.commons.collections.Predicate;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.archiva.dependency.graph.DependencyGraphEdge;
import org.apache.maven.archiva.model.DependencyScope;

/**
* EdgeExactScopePredicate
*
* @version $Id$
*/
public class EdgeExactScopePredicate
implements Predicate
{
private String scope;

public EdgeExactScopePredicate( String scope )
{
this.scope = scope;
}

public EdgeExactScopePredicate()
{
// The universal default for scope.
this.scope = DependencyScope.COMPILE;
}

public boolean evaluate( Object object )
{
boolean satisfies = false;

if ( object instanceof DependencyGraphEdge )
{
DependencyGraphEdge edge = (DependencyGraphEdge) object;
satisfies = StringUtils.equals( edge.getScope(), scope );
}

return satisfies;
}

public String getScope()
{
return scope;
}

public void setScope( String scope )
{
this.scope = scope;
}
}

+ 0
- 53
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/functors/EdgeExcludedPredicate.java View File

@@ -1,53 +0,0 @@
package org.apache.maven.archiva.dependency.graph.functors;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.commons.collections.Predicate;
import org.apache.maven.archiva.dependency.graph.DependencyGraph;
import org.apache.maven.archiva.dependency.graph.DependencyGraphEdge;

/**
* EdgeExcludedPredicate
*
* @version $Id$
*/
public class EdgeExcludedPredicate
implements Predicate
{
private static Predicate INSTANCE = new EdgeExcludedPredicate();

public static Predicate getInstance()
{
return INSTANCE;
}

public boolean evaluate( Object object )
{
boolean satisfies = false;

if ( object instanceof DependencyGraphEdge )
{
DependencyGraphEdge edge = (DependencyGraphEdge) object;
satisfies = ( edge.isDisabled() && ( edge.getDisabledType() == DependencyGraph.DISABLED_EXCLUDED ) );
}

return satisfies;
}
}

+ 0
- 61
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/functors/EdgeFromPredicate.java View File

@@ -1,61 +0,0 @@
package org.apache.maven.archiva.dependency.graph.functors;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.commons.collections.Predicate;
import org.apache.maven.archiva.dependency.graph.DependencyGraphEdge;
import org.apache.maven.archiva.dependency.graph.DependencyGraphNode;
import org.apache.maven.archiva.model.ArtifactReference;

/**
* Predicate returns true on any DependencyGraphEdge which has a
* specific FROM node.
*
* @version $Id$
*/
public class EdgeFromPredicate
implements Predicate
{
private ArtifactReference nodeRef;

public EdgeFromPredicate( ArtifactReference ref )
{
this.nodeRef = ref;
}

public EdgeFromPredicate( DependencyGraphNode node )
{
this( node.getArtifact() );
}

public boolean evaluate( Object object )
{
boolean satisfies = false;

if ( object instanceof DependencyGraphEdge )
{
DependencyGraphEdge edge = (DependencyGraphEdge) object;
satisfies = edge.getNodeFrom().equals( nodeRef );
}

return satisfies;
}

}

+ 0
- 48
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/functors/EdgeScopeClosure.java View File

@@ -1,48 +0,0 @@
package org.apache.maven.archiva.dependency.graph.functors;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.commons.collections.Closure;
import org.apache.maven.archiva.dependency.graph.DependencyGraphEdge;

/**
* Closure to set the edge scope.
*
* @version $Id$
*/
public class EdgeScopeClosure
implements Closure
{
private String scope;

public EdgeScopeClosure( String scope )
{
this.scope = scope;
}

public void execute( Object input )
{
if ( input instanceof DependencyGraphEdge )
{
DependencyGraphEdge edge = (DependencyGraphEdge) input;
edge.setScope( scope );
}
}
}

+ 0
- 54
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/functors/EdgeToPredicate.java View File

@@ -1,54 +0,0 @@
package org.apache.maven.archiva.dependency.graph.functors;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.commons.collections.Predicate;
import org.apache.maven.archiva.dependency.graph.DependencyGraphEdge;
import org.apache.maven.archiva.model.ArtifactReference;

/**
* EdgeToPredicate
*
* @version $Id$
*/
public class EdgeToPredicate
implements Predicate
{
private ArtifactReference nodeRef;

public EdgeToPredicate( ArtifactReference ref )
{
this.nodeRef = ref;
}

public boolean evaluate( Object object )
{
boolean satisfies = false;

if ( object instanceof DependencyGraphEdge )
{
DependencyGraphEdge edge = (DependencyGraphEdge) object;
satisfies = edge.getNodeTo().equals( nodeRef );
}

return satisfies;
}

}

+ 0
- 53
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/functors/EdgeWithinScopePredicate.java View File

@@ -1,53 +0,0 @@
package org.apache.maven.archiva.dependency.graph.functors;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.commons.collections.Predicate;
import org.apache.maven.archiva.dependency.graph.DependencyGraphEdge;
import org.apache.maven.archiva.model.DependencyScope;

/**
* EdgeWithinScopePredicate
*
* @version $Id$
*/
public class EdgeWithinScopePredicate
implements Predicate
{
private String scope;

public EdgeWithinScopePredicate( String scope )
{
this.scope = scope;
}

public boolean evaluate( Object object )
{
boolean satisfies = false;

if ( object instanceof DependencyGraphEdge )
{
DependencyGraphEdge edge = (DependencyGraphEdge) object;
satisfies = DependencyScope.isWithinScope( edge.getScope(), scope );
}

return satisfies;
}
}

+ 0
- 45
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/functors/NodeFromParentPredicate.java View File

@@ -1,45 +0,0 @@
package org.apache.maven.archiva.dependency.graph.functors;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.commons.collections.Predicate;
import org.apache.maven.archiva.dependency.graph.DependencyGraphNode;

/**
* Predicate for nodes that are flagged as from parent pom reference.
*
* @version $Id$
*/
public class NodeFromParentPredicate
implements Predicate
{

public boolean evaluate( Object object )
{
boolean satisfies = false;
if ( object instanceof DependencyGraphNode )
{
DependencyGraphNode node = (DependencyGraphNode) object;
satisfies = node.isFromParent();
}
return satisfies;
}

}

+ 0
- 53
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/functors/NodeInEdgePredicate.java View File

@@ -1,53 +0,0 @@
package org.apache.maven.archiva.dependency.graph.functors;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.commons.collections.Predicate;
import org.apache.maven.archiva.dependency.graph.DependencyGraphEdge;
import org.apache.maven.archiva.model.ArtifactReference;

/**
* NodeInEdgePredicate
*
* @version $Id$
*/
public class NodeInEdgePredicate
implements Predicate
{
private ArtifactReference nodeRef;

public NodeInEdgePredicate( ArtifactReference ref )
{
this.nodeRef = ref;
}

public boolean evaluate( Object object )
{
boolean satisfies = false;

if ( object instanceof DependencyGraphEdge )
{
DependencyGraphEdge edge = (DependencyGraphEdge) object;
satisfies = ( edge.getNodeFrom().equals( nodeRef ) || edge.getNodeTo().equals( nodeRef ) );
}

return satisfies;
}
}

+ 0
- 58
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/functors/NodePredicate.java View File

@@ -1,58 +0,0 @@
package org.apache.maven.archiva.dependency.graph.functors;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.commons.collections.Predicate;
import org.apache.maven.archiva.dependency.graph.DependencyGraphNode;
import org.apache.maven.archiva.model.ArtifactReference;

/**
* NodePredicate
*
* @version $Id$
*/
public class NodePredicate
implements Predicate
{
private ArtifactReference ref;

public NodePredicate( ArtifactReference ref )
{
this.ref = ref;
}

public NodePredicate( DependencyGraphNode node )
{
this( node.getArtifact() );
}

public boolean evaluate( Object object )
{
boolean satisfies = false;

if ( object instanceof DependencyGraphNode )
{
DependencyGraphNode node = (DependencyGraphNode) object;
satisfies = ref.equals( node.getArtifact() );
}

return satisfies;
}
}

+ 0
- 55
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/functors/OrphanedNodePredicate.java View File

@@ -1,55 +0,0 @@
package org.apache.maven.archiva.dependency.graph.functors;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.Predicate;
import org.apache.maven.archiva.dependency.graph.DependencyGraph;
import org.apache.maven.archiva.dependency.graph.DependencyGraphNode;

/**
* OrphanedNodePredicate
*
* @version $Id$
*/
public class OrphanedNodePredicate
implements Predicate
{
private DependencyGraph graph;

public OrphanedNodePredicate( DependencyGraph graph )
{
this.graph = graph;
}

public boolean evaluate( Object object )
{
boolean satisfies = false;

if ( object instanceof DependencyGraphNode )
{
DependencyGraphNode node = (DependencyGraphNode) object;
satisfies = CollectionUtils.isEmpty( graph.getEdgesTo( node ) );
}

return satisfies;
}

}

+ 0
- 43
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/functors/ToArtifactReferenceTransformer.java View File

@@ -1,43 +0,0 @@
package org.apache.maven.archiva.dependency.graph.functors;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.commons.collections.Transformer;
import org.apache.maven.archiva.dependency.graph.DependencyGraphNode;

/**
* Transform some common dependency graph objects into their
* ArtifactReference form.
*/
public class ToArtifactReferenceTransformer
implements Transformer
{
public Object transform( Object input )
{
if ( input instanceof DependencyGraphNode )
{
return ( (DependencyGraphNode) input ).getArtifact();
}

// TODO: Add more objects to transform here.

return input;
}
}

+ 0
- 52
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/functors/UnresolvedGraphNodePredicate.java View File

@@ -1,52 +0,0 @@
package org.apache.maven.archiva.dependency.graph.functors;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.commons.collections.Predicate;
import org.apache.maven.archiva.dependency.graph.DependencyGraphNode;

/**
* Predicate for unresolved {@link DependencyGraphNode} objects.
*
* @version $Id$
*/
public class UnresolvedGraphNodePredicate
implements Predicate
{
private static UnresolvedGraphNodePredicate INSTANCE = new UnresolvedGraphNodePredicate();

public static Predicate getInstance()
{
return INSTANCE;
}

public boolean evaluate( Object object )
{
boolean satisfies = false;

if ( object instanceof DependencyGraphNode )
{
DependencyGraphNode node = (DependencyGraphNode) object;
satisfies = !( node.isResolved() );
}

return satisfies;
}
}

+ 0
- 42
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/AbstractReduceEdgeVisitor.java View File

@@ -1,42 +0,0 @@
package org.apache.maven.archiva.dependency.graph.tasks;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.maven.archiva.dependency.graph.DependencyGraph;
import org.apache.maven.archiva.dependency.graph.DependencyGraphUtils;
import org.apache.maven.archiva.dependency.graph.walk.BaseVisitor;
import org.apache.maven.archiva.dependency.graph.walk.DependencyGraphVisitor;

/**
* AbstractReduceEdgeVisitor
*
* @version $Id$
*/
public abstract class AbstractReduceEdgeVisitor
extends BaseVisitor
implements DependencyGraphVisitor
{
public void finishGraph( DependencyGraph graph )
{
super.finishGraph( graph );
DependencyGraphUtils.cleanupOrphanedNodes( graph );
}
}

+ 0
- 210
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/DependencyManagementApplier.java View File

@@ -1,210 +0,0 @@
package org.apache.maven.archiva.dependency.graph.tasks;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.apache.maven.archiva.dependency.graph.DependencyGraph;
import org.apache.maven.archiva.dependency.graph.DependencyGraphBuilder;
import org.apache.maven.archiva.dependency.graph.DependencyGraphEdge;
import org.apache.maven.archiva.dependency.graph.DependencyGraphNode;
import org.apache.maven.archiva.dependency.graph.DependencyGraphUtils;
import org.apache.maven.archiva.dependency.graph.tasks.DependencyManagementStack.Rules;
import org.apache.maven.archiva.dependency.graph.walk.BaseVisitor;
import org.apache.maven.archiva.dependency.graph.walk.DependencyGraphVisitor;
import org.apache.maven.archiva.model.ArtifactReference;
import org.apache.maven.archiva.model.VersionedReference;

/**
* Takes a stack of DependencyManagement objects and applies them to the node in question.
* This merely sets the version / scope / and exclusions on the nodes, as defined by DependencyManagement.
*
* @version $Id$
*/
public class DependencyManagementApplier
extends BaseVisitor
implements DependencyGraphVisitor
{
private DependencyManagementStack depStack = new DependencyManagementStack();

private DependencyGraphBuilder builder;

/**
* Map of changes to node versions (that will likely cause a reorganization of
* the graph), this is tracked until the walk is complete, at which point the
* changes are applied to the graph.
*
* Performing graph changes of this scope during a walk of graph is hazardous,
* as you will be moving nodes around, mergeing nodes, dropping edges, etc.
*/
private Map<ArtifactReference, String> nodeVersionChanges = new HashMap<ArtifactReference, String>();

private int nodesAdded = 0;

public void discoverGraph( DependencyGraph graph )
{
super.discoverGraph( graph );
nodeVersionChanges.clear();
depStack.reset();
nodesAdded = 0;
}

public void discoverNode( DependencyGraphNode node )
{
super.discoverNode( node );

depStack.push( node );

for ( DependencyGraphEdge edge : graph.getEdgesFrom( node ) )
{
Rules rules = depStack.getRules( edge );

if ( rules == null )
{
// No rules for edge, skip it.
continue;
}

DependencyGraphNode subnode = graph.getNode( edge.getNodeTo() );

/* There are 3 steps to processing the DependencyManagement. */

/* 1) Add exclusions to node ________________________________________________ */
node.getExcludes().addAll( rules.exclusions );

/* 2) Track version changes to node _________________________________________ */

// This is the version as specified by the rules.
String specifiedVersion = rules.artifact.getVersion();

// This is the version as being tracked by the nodeVersionChanges map.
String trackedVersion = (String) nodeVersionChanges.get( edge.getNodeTo() );

// This is the version of the subnode.
String nodeVersion = subnode.getArtifact().getVersion();

// This is the actual version as determined by tracked and subnode
String actualVersion = StringUtils.defaultString( trackedVersion, nodeVersion );

// If the specified version changes the actual version ...
if ( !StringUtils.equals( specifiedVersion, actualVersion ) )
{
// ... save this new value to be track ( for processing in #finishedGraph )
nodeVersionChanges.put( edge.getNodeTo(), specifiedVersion );
}

/* 3) Update scope to edge __________________________________________________ */

if ( StringUtils.isNotBlank( rules.scope ) )
{
edge.setScope( rules.scope );
}
}
}

public void finishNode( DependencyGraphNode node )
{
super.finishNode( node );

depStack.pop();
}

public void finishGraph( DependencyGraph graph )
{
super.finishGraph( graph );

for ( ArtifactReference ref : this.nodeVersionChanges.keySet() )
{
String toVersion = this.nodeVersionChanges.get( ref );

collapseVersions( graph, ref, ref.getVersion(), toVersion );
}
}

/**
* Collapses Versions of nodes.
*
* Takes two nodes, with differing versions.
*
* 1) Removes the FROM edges connected to the FROM node
* 2) Moves the TO edges connected to the FROM node to the TO node.
* 3) Removes the FROM node (which is now orphaned)
*
* @param graph the graph to perform operation on
* @param fromRef the artifact reference of the FROM node.
* @param fromVersion the version of the FROM node
* @param toVersion the version of the TO node
*/
private void collapseVersions( DependencyGraph graph, ArtifactReference fromRef, String fromVersion,
String toVersion )
{
if ( StringUtils.equals( fromVersion, toVersion ) )
{
// No point in doing anything. nothing has changed.
return;
}

ArtifactReference toRef = new ArtifactReference();
toRef.setGroupId( fromRef.getGroupId() );
toRef.setArtifactId( fromRef.getArtifactId() );
toRef.setVersion( toVersion );
toRef.setClassifier( fromRef.getClassifier() );
toRef.setType( fromRef.getType() );

DependencyGraphNode nodeFROM = graph.getNode( fromRef );
DependencyGraphNode nodeTO = graph.getNode( toRef );

if ( nodeTO == null )
{
// new node doesn't exist in graph (yet)
nodeTO = new DependencyGraphNode( toRef );
nodeTO.setResolved( false );

graph.addNode( nodeTO );

VersionedReference projectRef = new VersionedReference();
projectRef.setGroupId( toRef.getGroupId() );
projectRef.setArtifactId( toRef.getArtifactId() );
projectRef.setVersion( toRef.getVersion() );

builder.resolveNode( graph, nodeTO, projectRef );
nodesAdded++;
}

DependencyGraphUtils.collapseNodes( graph, nodeFROM, nodeTO );
}

public DependencyGraphBuilder getBuilder()
{
return builder;
}

public void setBuilder( DependencyGraphBuilder builder )
{
this.builder = builder;
}

public boolean hasCreatedNodes()
{
return ( nodesAdded > 0 );
}
}

+ 0
- 146
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/DependencyManagementStack.java View File

@@ -1,146 +0,0 @@
package org.apache.maven.archiva.dependency.graph.tasks;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Stack;

import org.apache.commons.collections.iterators.ReverseListIterator;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.archiva.dependency.graph.DependencyGraphEdge;
import org.apache.maven.archiva.dependency.graph.DependencyGraphKeys;
import org.apache.maven.archiva.dependency.graph.DependencyGraphNode;
import org.apache.maven.archiva.model.ArtifactReference;
import org.apache.maven.archiva.model.Dependency;
import org.apache.maven.archiva.model.Exclusion;

/**
* DependencyManagementStack
*
* @version $Id$
*/
public class DependencyManagementStack
{
public class Rules
{
public ArtifactReference artifact;

public String scope;

public Set<String> exclusions = new HashSet<String>();

public void addAllExclusions( List<Exclusion> depExclusions )
{
for ( Exclusion ref : depExclusions )
{
String key = DependencyGraphKeys.toManagementKey( ref );
exclusions.add( key );
}
}
}

private Stack<DependencyGraphNode> depmanStack = new Stack<DependencyGraphNode>();

private Map<String, Rules> depMap = new HashMap<String, Rules>();

private void generateDepMap()
{
depMap.clear();

// Using a reverse iterator to ensure that we read the
// stack from last in to first in
ReverseListIterator it = new ReverseListIterator( depmanStack );
while ( it.hasNext() )
{
DependencyGraphNode node = (DependencyGraphNode) it.next();

addDependencies( node.getDependencyManagement() );
}
}

private void addDependencies( List<Dependency> dependencies )
{
for ( Dependency dep : dependencies )
{
String key = DependencyGraphKeys.toManagementKey( dep );

Rules merged = (Rules) depMap.get( key );
if ( merged == null )
{
// New map entry.
merged = new Rules();
merged.artifact = new ArtifactReference();
merged.artifact.setGroupId( dep.getGroupId() );
merged.artifact.setArtifactId( dep.getArtifactId() );
merged.artifact.setClassifier( dep.getClassifier() );
merged.artifact.setType( dep.getType() );
}

merged.artifact.setVersion( dep.getVersion() );
if ( StringUtils.isNotBlank( dep.getScope() ) )
{
merged.scope = dep.getScope();
}

merged.addAllExclusions( dep.getExclusions() );

depMap.put( key, merged );
}
}

public Rules getRules( DependencyGraphEdge edge )
{
return getRules( edge.getNodeTo() );
}

public Rules getRules( DependencyGraphNode node )
{
return getRules( node.getArtifact() );
}

public Rules getRules( ArtifactReference ref )
{
String key = DependencyGraphKeys.toManagementKey( ref );
return (Rules) depMap.get( key );
}

public void push( DependencyGraphNode node )
{
depmanStack.push( node );
generateDepMap();
}

public DependencyGraphNode pop()
{
DependencyGraphNode node = (DependencyGraphNode) depmanStack.pop();
generateDepMap();
return node;
}

public void reset()
{
depmanStack.clear();
depMap.clear();
}
}

+ 0
- 47
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/FlagCyclicEdgesTask.java View File

@@ -1,47 +0,0 @@
package org.apache.maven.archiva.dependency.graph.tasks;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.maven.archiva.dependency.graph.DependencyGraph;
import org.apache.maven.archiva.dependency.graph.GraphTask;
import org.apache.maven.archiva.dependency.graph.walk.DependencyGraphWalker;
import org.apache.maven.archiva.dependency.graph.walk.WalkDepthFirstSearch;

/**
* FlagCyclicEdgesTask
*
* @version $Id$
*/
public class FlagCyclicEdgesTask
implements GraphTask
{

public void executeTask( DependencyGraph graph )
{
DependencyGraphWalker walker = new WalkDepthFirstSearch();
FlagExcludedEdgesVisitor excludedEdgeResolver = new FlagExcludedEdgesVisitor();
walker.visit( graph, excludedEdgeResolver );
}

public String getTaskId()
{
return "flag-cyclic-edges";
}
}

+ 0
- 69
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/FlagCyclicEdgesVisitor.java View File

@@ -1,69 +0,0 @@
package org.apache.maven.archiva.dependency.graph.tasks;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.maven.archiva.dependency.graph.DependencyGraph;
import org.apache.maven.archiva.dependency.graph.DependencyGraphEdge;
import org.apache.maven.archiva.dependency.graph.walk.BaseVisitor;
import org.apache.maven.archiva.dependency.graph.walk.DependencyGraphVisitor;
import org.apache.maven.archiva.dependency.graph.walk.DependencyGraphWalker;
import org.apache.maven.archiva.model.ArtifactReference;

import java.util.HashSet;
import java.util.Set;

/**
* FlagCyclicEdgesVisitor
*
* @version $Id$
*/
public class FlagCyclicEdgesVisitor
extends BaseVisitor
implements DependencyGraphVisitor
{
private DependencyGraphWalker walker;

private Set<DependencyGraphEdge> cyclicEdges = new HashSet<DependencyGraphEdge>();

public FlagCyclicEdgesVisitor( DependencyGraphWalker walker )
{
this.walker = walker;
}

public void discoverEdge( DependencyGraphEdge edge )
{
ArtifactReference artifact = edge.getNodeTo();

// Process for cyclic edges.
if ( walker.getNodeVisitState( artifact ) == DependencyGraphWalker.PROCESSING )
{
edge.setDisabled( true );
edge.setDisabledType( DependencyGraph.DISABLED_CYCLIC );
edge.setDisabledReason( "Cycle detected" );
// TODO: insert into reason the path for the cycle that was detected.
cyclicEdges.add( edge );
}
}

public Set<DependencyGraphEdge> getCyclicEdges()
{
return cyclicEdges;
}
}

+ 0
- 46
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/FlagExcludedEdgesTask.java View File

@@ -1,46 +0,0 @@
package org.apache.maven.archiva.dependency.graph.tasks;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.maven.archiva.dependency.graph.DependencyGraph;
import org.apache.maven.archiva.dependency.graph.GraphTask;
import org.apache.maven.archiva.dependency.graph.walk.DependencyGraphWalker;
import org.apache.maven.archiva.dependency.graph.walk.WalkDepthFirstSearch;

/**
* FlagExcludedEdgesTask
*
* @version $Id$
*/
public class FlagExcludedEdgesTask
implements GraphTask
{
public void executeTask( DependencyGraph graph )
{
DependencyGraphWalker walker = new WalkDepthFirstSearch();
FlagExcludedEdgesVisitor excludedEdgeResolver = new FlagExcludedEdgesVisitor();
walker.visit( graph, excludedEdgeResolver );
}

public String getTaskId()
{
return "flag-excluded-edges";
}
}

+ 0
- 81
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/FlagExcludedEdgesVisitor.java View File

@@ -1,81 +0,0 @@
package org.apache.maven.archiva.dependency.graph.tasks;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import java.util.Stack;

import org.apache.maven.archiva.dependency.graph.DependencyGraph;
import org.apache.maven.archiva.dependency.graph.DependencyGraphEdge;
import org.apache.maven.archiva.dependency.graph.DependencyGraphKeys;
import org.apache.maven.archiva.dependency.graph.DependencyGraphNode;
import org.apache.maven.archiva.dependency.graph.walk.BaseVisitor;
import org.apache.maven.archiva.dependency.graph.walk.DependencyGraphVisitor;
import org.apache.maven.archiva.model.ArtifactReference;

/**
* FlagExcludedEdgesVisitor
*
* @version $Id$
*/
public class FlagExcludedEdgesVisitor
extends BaseVisitor
implements DependencyGraphVisitor
{
private Stack<DependencyGraphNode> nodePath = new Stack<DependencyGraphNode>();

public void discoverEdge( DependencyGraphEdge edge )
{
ArtifactReference artifact = edge.getNodeTo();
// Process for excluded edges.
String toKey = DependencyGraphKeys.toManagementKey( artifact );
for ( DependencyGraphNode pathNode : this.nodePath )
{
// Process dependency declared exclusions.
if ( pathNode.getExcludes().contains( toKey ) )
{
edge.setDisabled( true );
edge.setDisabledType( DependencyGraph.DISABLED_EXCLUDED );
String whoExcluded = DependencyGraphKeys.toKey( pathNode );
edge.setDisabledReason( "Specifically Excluded by " + whoExcluded );
break;
}
}
}

public void discoverNode( DependencyGraphNode node )
{
super.discoverNode( node );
nodePath.push( node );
}

public void finishNode( DependencyGraphNode node )
{
super.finishNode( node );
DependencyGraphNode pathNode = (DependencyGraphNode) nodePath.pop();
if ( !node.equals( pathNode ) )
{
String pathNodeKey = ArtifactReference.toKey( pathNode.getArtifact() );
String finishNodeKey = ArtifactReference.toKey( node.getArtifact() );
throw new IllegalStateException( "Encountered bad visitor state. Expected finish on node " + pathNodeKey
+ ", but instead got notified of node " + finishNodeKey );
}
}
}

+ 0
- 80
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/GraphCopier.java View File

@@ -1,80 +0,0 @@
package org.apache.maven.archiva.dependency.graph.tasks;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.maven.archiva.dependency.graph.DependencyGraph;
import org.apache.maven.archiva.dependency.graph.DependencyGraphEdge;
import org.apache.maven.archiva.dependency.graph.DependencyGraphNode;
import org.apache.maven.archiva.dependency.graph.walk.BaseVisitor;
import org.apache.maven.archiva.dependency.graph.walk.DependencyGraphVisitor;

/**
* GraphCopier
*
* @version $Id$
*/
public class GraphCopier
extends BaseVisitor
implements DependencyGraphVisitor
{
protected DependencyGraph copiedGraph;

public DependencyGraph getGraph()
{
return copiedGraph;
}

public void setGraph( DependencyGraph graph )
{
this.copiedGraph = graph;
}

public void discoverNode( DependencyGraphNode node )
{
if ( copiedGraph == null )
{
copiedGraph = new DependencyGraph( node );
}
}

/**
* Be sure to override and NOT call this method in your sub class,
* if you want to copy edges based on some kind of criteria.
*/
public void discoverEdge( DependencyGraphEdge edge )
{
copyEdge( edge );
}

public void copyEdge( DependencyGraphEdge edge )
{
DependencyGraphNode nodeFrom = graph.getNode( edge.getNodeFrom() );
DependencyGraphNode nodeTo = graph.getNode( edge.getNodeTo() );

this.copiedGraph.addNode( nodeFrom );
this.copiedGraph.addNode( nodeTo );
this.copiedGraph.addEdge( edge );
}

public void reset()
{
this.copiedGraph = null;
}
}

+ 0
- 47
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/PopulateDependencyManagementTask.java View File

@@ -1,47 +0,0 @@
package org.apache.maven.archiva.dependency.graph.tasks;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.maven.archiva.dependency.graph.DependencyGraph;
import org.apache.maven.archiva.dependency.graph.GraphTask;
import org.apache.maven.archiva.dependency.graph.PotentialCyclicEdgeProducer;
import org.apache.maven.archiva.dependency.graph.walk.DependencyGraphWalker;
import org.apache.maven.archiva.dependency.graph.walk.WalkDepthFirstSearch;

/**
* PopulateDependencyManagementTask
*
* @version $Id$
*/
public class PopulateDependencyManagementTask
implements GraphTask, PotentialCyclicEdgeProducer
{
public void executeTask( DependencyGraph graph )
{
DependencyGraphWalker walker = new WalkDepthFirstSearch();
DependencyManagementApplier depManApplier = new DependencyManagementApplier();
walker.visit( graph, depManApplier );
}

public String getTaskId()
{
return "populate-dependency-management";
}
}

+ 0
- 86
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/PopulateGraphMasterTask.java View File

@@ -1,86 +0,0 @@
package org.apache.maven.archiva.dependency.graph.tasks;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.maven.archiva.dependency.graph.DependencyGraph;
import org.apache.maven.archiva.dependency.graph.DependencyGraphBuilder;
import org.apache.maven.archiva.dependency.graph.DependencyGraphUtils;
import org.apache.maven.archiva.dependency.graph.GraphTask;
import org.apache.maven.archiva.dependency.graph.GraphTaskException;
import org.apache.maven.archiva.dependency.graph.walk.DependencyGraphWalker;
import org.apache.maven.archiva.dependency.graph.walk.WalkDepthFirstSearch;

/**
* PopulateGraphMasterTask - will perform a resolve / depman apply loop until the graph is fully populated.
*
* @version $Id$
*/
public class PopulateGraphMasterTask
implements GraphTask
{
private DependencyGraphBuilder builder;

private ResolveGraphTask resolveGraphTask = new ResolveGraphTask();

private DependencyManagementApplier depManApplier = new DependencyManagementApplier();

public void executeTask( DependencyGraph graph )
throws GraphTaskException
{
DependencyGraphWalker walker = new WalkDepthFirstSearch();

boolean done = false;
int maxiters = 5;

while ( !done )
{
resolveGraphTask.executeTask( graph );
walker.visit( graph, depManApplier );

if ( !depManApplier.hasCreatedNodes() || ( maxiters < 0 ) )
{
done = true;
break;
}

maxiters--;
}

DependencyGraphUtils.cleanupOrphanedNodes( graph );
}

public String getTaskId()
{
return "populate-graph";
}

public DependencyGraphBuilder getBuilder()
{
return builder;
}

public void setBuilder( DependencyGraphBuilder builder )
{
this.builder = builder;
this.resolveGraphTask.setBuilder( builder );
this.depManApplier.setBuilder( builder );
}

}

+ 0
- 48
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/ReduceEnabledEdgesTask.java View File

@@ -1,48 +0,0 @@
package org.apache.maven.archiva.dependency.graph.tasks;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.commons.collections.functors.TruePredicate;
import org.apache.maven.archiva.dependency.graph.DependencyGraph;
import org.apache.maven.archiva.dependency.graph.GraphTask;
import org.apache.maven.archiva.dependency.graph.walk.DependencyGraphWalker;
import org.apache.maven.archiva.dependency.graph.walk.WalkDepthFirstSearch;

/**
* ReduceEnabledEdgesTask
*
* @version $Id$
*/
public class ReduceEnabledEdgesTask
implements GraphTask
{
public void executeTask( DependencyGraph graph )
{
DependencyGraphWalker walker = new WalkDepthFirstSearch();
walker.setEdgePredicate( TruePredicate.getInstance() );
ReduceEnabledEdgesVisitor reduceEnabledEdgesResolver = new ReduceEnabledEdgesVisitor();
walker.visit( graph, reduceEnabledEdgesResolver );
}

public String getTaskId()
{
return "reduce-enabled-edges";
}
}

+ 0
- 41
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/ReduceEnabledEdgesVisitor.java View File

@@ -1,41 +0,0 @@
package org.apache.maven.archiva.dependency.graph.tasks;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.maven.archiva.dependency.graph.DependencyGraphEdge;
import org.apache.maven.archiva.dependency.graph.walk.DependencyGraphVisitor;

/**
* Removes all disabled edges from the graph.
*
* @version $Id$
*/
public class ReduceEnabledEdgesVisitor
extends AbstractReduceEdgeVisitor
implements DependencyGraphVisitor
{
public void discoverEdge( DependencyGraphEdge edge )
{
if ( edge.isDisabled() )
{
super.graph.removeEdge( edge );
}
}
}

+ 0
- 63
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/ReduceScopeTask.java View File

@@ -1,63 +0,0 @@
package org.apache.maven.archiva.dependency.graph.tasks;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.maven.archiva.dependency.graph.DependencyGraph;
import org.apache.maven.archiva.dependency.graph.GraphTask;
import org.apache.maven.archiva.dependency.graph.walk.DependencyGraphWalker;
import org.apache.maven.archiva.dependency.graph.walk.WalkDepthFirstSearch;

/**
* ReduceScopeTask
*
* @version $Id$
*/
public class ReduceScopeTask
implements GraphTask
{
private String scope;

public ReduceScopeTask( String scope )
{
this.scope = scope;
}

public void executeTask( DependencyGraph graph )
{
DependencyGraphWalker walker = new WalkDepthFirstSearch();
ReduceScopeVisitor reduceScopeResolver = new ReduceScopeVisitor( this.scope );
walker.visit( graph, reduceScopeResolver );
}

public String getScope()
{
return scope;
}

public void setScope( String scope )
{
this.scope = scope;
}

public String getTaskId()
{
return "reduce-scope";
}
}

+ 0
- 50
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/ReduceScopeVisitor.java View File

@@ -1,50 +0,0 @@
package org.apache.maven.archiva.dependency.graph.tasks;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.commons.collections.Predicate;
import org.apache.maven.archiva.dependency.graph.DependencyGraphEdge;
import org.apache.maven.archiva.dependency.graph.functors.EdgeWithinScopePredicate;
import org.apache.maven.archiva.dependency.graph.walk.DependencyGraphVisitor;

/**
* ReduceScopeVisitor
*
* @version $Id$
*/
public class ReduceScopeVisitor
extends AbstractReduceEdgeVisitor
implements DependencyGraphVisitor
{
private Predicate scopedPredicate;

public ReduceScopeVisitor( String scope )
{
scopedPredicate = new EdgeWithinScopePredicate( scope );
}

public void discoverEdge( DependencyGraphEdge edge )
{
if ( !scopedPredicate.evaluate( edge ) )
{
super.graph.removeEdge( edge );
}
}
}

+ 0
- 47
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/ReduceTransitiveEdgesTask.java View File

@@ -1,47 +0,0 @@
package org.apache.maven.archiva.dependency.graph.tasks;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.maven.archiva.dependency.graph.DependencyGraph;
import org.apache.maven.archiva.dependency.graph.GraphTask;
import org.apache.maven.archiva.dependency.graph.walk.DependencyGraphWalker;
import org.apache.maven.archiva.dependency.graph.walk.WalkBreadthFirstSearch;

/**
* ReduceTransitiveEdgesTask
*
* @version $Id$
*/
public class ReduceTransitiveEdgesTask
implements GraphTask
{

public void executeTask( DependencyGraph graph )
{
DependencyGraphWalker walker = new WalkBreadthFirstSearch();
ReduceTransitiveEdgesVisitor reduceTransitiveEdgesResolver = new ReduceTransitiveEdgesVisitor();
walker.visit( graph, reduceTransitiveEdgesResolver );
}

public String getTaskId()
{
return "reduce-transitive-edges";
}
}

+ 0
- 153
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/ReduceTransitiveEdgesVisitor.java View File

@@ -1,153 +0,0 @@
package org.apache.maven.archiva.dependency.graph.tasks;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.maven.archiva.dependency.graph.DependencyGraph;
import org.apache.maven.archiva.dependency.graph.DependencyGraphEdge;
import org.apache.maven.archiva.dependency.graph.DependencyGraphKeys;
import org.apache.maven.archiva.dependency.graph.DependencyGraphNode;
import org.apache.maven.archiva.dependency.graph.walk.DependencyGraphVisitor;

/**
* Perform a transitive reduction of the graph.
*
* @version $Id$
*/
public class ReduceTransitiveEdgesVisitor
extends AbstractReduceEdgeVisitor
implements DependencyGraphVisitor
{
class EdgeInfo
{
public DependencyGraphEdge edge;

public int depth = Integer.MAX_VALUE;
}

class EdgeInfoDepthComparator
implements Comparator<EdgeInfo>
{
public int compare( EdgeInfo obj0, EdgeInfo obj1 )
{
return obj0.depth - obj1.depth;
}
}

/**
* A Map of &lt;(Node To) ArtifactReference, Map of &lt;(Node From) ArtifactReference, EdgeInfo&gt;&gt;
*/
private Map<String, Map<String, EdgeInfo>> nodeDistanceMap = new HashMap<String, Map<String, EdgeInfo>>();

private int currentDepth;

public void discoverGraph( DependencyGraph graph )
{
super.discoverGraph( graph );
nodeDistanceMap.clear();
currentDepth = 0;
}

public void discoverEdge( DependencyGraphEdge edge )
{
/* WARNING: it is unwise to remove the edge at this point.
* as modifying the graph as it's being walked is dangerous.
*
* Just record the edge's current depth.
*/

String nodeTo = DependencyGraphKeys.toKey( edge.getNodeTo() );
String nodeFrom = DependencyGraphKeys.toKey( edge.getNodeFrom() );

// Get sub-map
Map<String,EdgeInfo> edgeInfoMap = nodeDistanceMap.get( nodeTo );

// Create sub-map if not present (yet)
if ( edgeInfoMap == null )
{
edgeInfoMap = new HashMap<String,EdgeInfo>();
nodeDistanceMap.put( nodeTo, edgeInfoMap );
}

// Get sub-map-value.
EdgeInfo edgeInfo = (EdgeInfo) edgeInfoMap.get( nodeFrom );

if ( edgeInfo == null )
{
// Create a new edgeinfo.
edgeInfo = new EdgeInfo();
edgeInfo.edge = edge;
edgeInfo.depth = currentDepth;
edgeInfoMap.put( nodeFrom, edgeInfo );
}
// test the current depth, if it is less than previous depth, save it
else if ( currentDepth < edgeInfo.depth )
{
edgeInfo.depth = currentDepth;
edgeInfoMap.put( nodeFrom, edgeInfo );
}

nodeDistanceMap.put( nodeTo, edgeInfoMap );
}

public void discoverNode( DependencyGraphNode node )
{
super.discoverNode( node );
currentDepth++;

}

public void finishNode( DependencyGraphNode node )
{
super.finishNode( node );
currentDepth--;
}

public void finishGraph( DependencyGraph graph )
{
super.finishGraph( graph );

// Now we prune/remove the edges that are transitive in nature.

Comparator<EdgeInfo> edgeInfoDepthComparator = new EdgeInfoDepthComparator();

for ( Map<String, EdgeInfo> edgeInfoMap : nodeDistanceMap.values() )
{
if ( edgeInfoMap.size() > 1 )
{
List<EdgeInfo> edgeInfos = new ArrayList<EdgeInfo>();
edgeInfos.addAll( edgeInfoMap.values() );
Collections.sort( edgeInfos, edgeInfoDepthComparator );

for ( int i = 1; i < edgeInfos.size(); i++ )
{
EdgeInfo edgeInfo = (EdgeInfo) edgeInfos.get( i );
graph.removeEdge( edgeInfo.edge );
}
}
}
}
}

+ 0
- 89
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/RefineConflictsTask.java View File

@@ -1,89 +0,0 @@
package org.apache.maven.archiva.dependency.graph.tasks;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.map.MultiValueMap;
import org.apache.maven.archiva.dependency.graph.DependencyGraph;
import org.apache.maven.archiva.dependency.graph.DependencyGraphKeys;
import org.apache.maven.archiva.dependency.graph.DependencyGraphNode;
import org.apache.maven.archiva.dependency.graph.GraphTask;
import org.apache.maven.archiva.dependency.graph.PotentialCyclicEdgeProducer;
import org.apache.maven.archiva.dependency.graph.functors.ToArtifactReferenceTransformer;
import org.apache.maven.archiva.dependency.graph.walk.DependencyGraphWalker;
import org.apache.maven.archiva.dependency.graph.walk.WalkDepthFirstSearch;

/**
* RefineConflictsTask
*
* @version $Id$
*/
public class RefineConflictsTask
implements GraphTask, PotentialCyclicEdgeProducer
{

@SuppressWarnings("unchecked")
public void executeTask( DependencyGraph graph )
{
DependencyGraphWalker walker = new WalkDepthFirstSearch();
RefineConflictsVisitor refineConflictsVisitor = new RefineConflictsVisitor();
MultiValueMap depMap = new MultiValueMap();

// Identify deps that need to be resolved.
for ( DependencyGraphNode node : graph.getNodes() )
{
String key = DependencyGraphKeys.toManagementKey( node.getArtifact() );
// This will add this node to the specified key, not replace a previous one.
depMap.put( key, node );
}

// Process those depMap entries with more than 1 value.
ToArtifactReferenceTransformer nodeToArtifact = new ToArtifactReferenceTransformer();

Iterator<Map.Entry<String,Collection<DependencyGraphNode>>> it = depMap.entrySet().iterator();
while ( it.hasNext() )
{
Map.Entry<String,Collection<DependencyGraphNode>> entry = it.next();
Collection<DependencyGraphNode> nodes = entry.getValue();
if ( nodes.size() > 1 )
{
List<DependencyGraphNode> conflictingArtifacts = new ArrayList<DependencyGraphNode>();
conflictingArtifacts.addAll( nodes );
CollectionUtils.transform( conflictingArtifacts, nodeToArtifact );

refineConflictsVisitor.resetConflictingArtifacts();
refineConflictsVisitor.addAllConflictingArtifacts( conflictingArtifacts );
walker.visit( graph, refineConflictsVisitor );
}
}
}

public String getTaskId()
{
return "refine-conflicts";
}
}

+ 0
- 292
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/RefineConflictsVisitor.java View File

@@ -1,292 +0,0 @@
package org.apache.maven.archiva.dependency.graph.tasks;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.collections.Predicate;
import org.apache.commons.collections.comparators.ReverseComparator;
import org.apache.commons.collections.functors.NotPredicate;
import org.apache.commons.collections.list.TypedList;
import org.apache.maven.archiva.dependency.graph.DependencyGraph;
import org.apache.maven.archiva.dependency.graph.DependencyGraphEdge;
import org.apache.maven.archiva.dependency.graph.DependencyGraphKeys;
import org.apache.maven.archiva.dependency.graph.DependencyGraphNode;
import org.apache.maven.archiva.dependency.graph.DependencyGraphUtils;
import org.apache.maven.archiva.dependency.graph.walk.BaseVisitor;
import org.apache.maven.archiva.dependency.graph.walk.DependencyGraphVisitor;
import org.apache.maven.archiva.model.ArtifactReference;

/**
* RefineConflictsVisitor
*
* @version $Id$
*/
public class RefineConflictsVisitor
extends BaseVisitor
implements DependencyGraphVisitor
{
class DepthComparator
implements Comparator<NodeLocation>
{
public int compare( NodeLocation obj0, NodeLocation obj1 )
{
return obj0.depth - obj1.depth;
}
}

class NodeLocation
{
public ArtifactReference artifact;

public DependencyGraphEdge edge;

public int depth;

public NodeLocation( ArtifactReference artifact, DependencyGraphEdge edge, int depth )
{
this.artifact = artifact;
this.edge = edge;
this.depth = depth;
}
}

class NodeLocationPredicate
implements Predicate
{
private ArtifactReference artifact;

public NodeLocationPredicate( ArtifactReference artifact )
{
this.artifact = artifact;
}

public NodeLocationPredicate( DependencyGraphNode node )
{
this( node.getArtifact() );
}

public boolean evaluate( Object object )
{
boolean satisfies = false;

if ( object instanceof NodeLocation )
{
NodeLocation nodeloc = (NodeLocation) object;
satisfies = nodeloc.artifact.equals( artifact );
}

return satisfies;
}

}

class NodeLocationVersionComparator
implements Comparator<NodeLocation>
{
public int compare( NodeLocation o1, NodeLocation o2 )
{
if ( o1 == null && o2 == null )
{
return 0;
}

if ( o1 == null && o2 != null )
{
return 1;
}

if ( o1 != null && o2 == null )
{
return -1;
}

// String version1 = o1.artifact.getVersion();
// String version2 = o2.artifact.getVersion();
//
// VersionComparator.getInstance().compare( version1, version2 );
return 0;
}
}

class DistantNodeLocationPredicate
implements Predicate
{
private int cutoff;

public DistantNodeLocationPredicate( int distantCutoff )
{
this.cutoff = distantCutoff;
}

public boolean evaluate( Object object )
{
boolean satisfies = false;

if ( object instanceof NodeLocation )
{
NodeLocation nodeloc = (NodeLocation) object;
satisfies = ( nodeloc.depth >= this.cutoff );
}

return satisfies;
}
}

private List<DependencyGraphNode> conflictingArtifacts;

private Map<String,NodeLocation> foundNodesMap = new HashMap<String, NodeLocation>();

private int currentDepth = 0;

private DependencyGraph currentGraph;

@SuppressWarnings("unchecked")
public RefineConflictsVisitor()
{
conflictingArtifacts = TypedList.decorate( new ArrayList<ArtifactReference>(), ArtifactReference.class );
}

public void discoverGraph( DependencyGraph graph )
{
super.discoverGraph( graph );
this.currentGraph = graph;
this.foundNodesMap.clear();
}

public void discoverNode( DependencyGraphNode node )
{
super.discoverNode( node );

currentDepth++;

List<DependencyGraphEdge> edgesFrom = currentGraph.getEdgesFrom( node );
for ( DependencyGraphEdge edge : edgesFrom )
{
if ( this.conflictingArtifacts.contains( edge.getNodeTo() ) )
{
String nodeKey = DependencyGraphKeys.toKey( edge.getNodeTo() );
// Check for existing NodeLocation with same key
NodeLocation nodeloc = this.foundNodesMap.get( nodeKey );

if ( ( nodeloc == null ) || ( currentDepth < nodeloc.depth ) )
{
nodeloc = new NodeLocation( edge.getNodeTo(), edge, currentDepth );
this.foundNodesMap.put( nodeKey, nodeloc );
}
}
}
}

public void finishGraph( DependencyGraph graph )
{
super.finishGraph( graph );

if ( MapUtils.isEmpty( this.foundNodesMap ) )
{
return;
}

// Find winning node.
ArtifactReference winningArtifact = findWinningArtifact( this.foundNodesMap.values() );
DependencyGraphNode winningNode = graph.getNode( winningArtifact );

// Gather up Losing Nodes.
Set<NodeLocation> losingNodes = new HashSet<NodeLocation>();
Predicate losersPredicate = NotPredicate.getInstance( new NodeLocationPredicate( winningArtifact ) );
CollectionUtils.select( this.foundNodesMap.values(), losersPredicate, losingNodes );

// Swing losing nodes to winning node.
for ( NodeLocation losingNodeLoc : losingNodes )
{
DependencyGraphNode losingNode = graph.getNode( losingNodeLoc.artifact );
DependencyGraphUtils.collapseNodes( graph, losingNode, winningNode );
}
}

@SuppressWarnings("unchecked")
private ArtifactReference findWinningArtifact( Collection<NodeLocation> nodes )
{
List<NodeLocation> remainingNodes = new ArrayList<NodeLocation>();
remainingNodes.addAll( nodes );

/* .\ Filter by Depth \.____________________________________________________ */

// Sort by depth.
Collections.sort( remainingNodes, new DepthComparator() );

// Determine 'closest' node depth.
NodeLocation nearestNode = remainingNodes.get( 0 );
int nearest = nearestNode.depth;

// Filter out distant nodes.
Predicate distantLocations = new DistantNodeLocationPredicate( nearest );
CollectionUtils.filter( remainingNodes, distantLocations );

// Do we have 1 node left?
if ( remainingNodes.size() == 1 )
{
// A winner!
NodeLocation nodeloc = remainingNodes.get( 0 );
return nodeloc.artifact;
}

/* .\ Filter by Newest Version \.___________________________________________ */

// We have 2 or more nodes that are equal distance from the root.
// Determine which one is 'newest' based on version id.
Collections.sort( remainingNodes, new ReverseComparator( new NodeLocationVersionComparator() ) );

NodeLocation nodeloc = remainingNodes.get( 0 );
return nodeloc.artifact;
}

public void finishNode( DependencyGraphNode node )
{
super.finishNode( node );
currentDepth--;
}

public List<DependencyGraphNode> getConflictingArtifacts()
{
return conflictingArtifacts;
}

public void addAllConflictingArtifacts( Collection<DependencyGraphNode> nodes )
{
this.conflictingArtifacts.addAll( nodes );
}

public void resetConflictingArtifacts()
{
this.conflictingArtifacts.clear();
}
}

+ 0
- 108
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/ResolveGraphTask.java View File

@@ -1,108 +0,0 @@
package org.apache.maven.archiva.dependency.graph.tasks;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.commons.collections.CollectionUtils;
import org.apache.maven.archiva.dependency.graph.DependencyGraph;
import org.apache.maven.archiva.dependency.graph.DependencyGraphBuilder;
import org.apache.maven.archiva.dependency.graph.DependencyGraphNode;
import org.apache.maven.archiva.dependency.graph.GraphTask;
import org.apache.maven.archiva.dependency.graph.PotentialCyclicEdgeProducer;
import org.apache.maven.archiva.dependency.graph.functors.UnresolvedGraphNodePredicate;
import org.apache.maven.archiva.model.VersionedReference;

/**
* Loop through the unresolved nodes and resolve them, until there
* are no more unresolved nodes.
*
* @version $Id$
*/
public class ResolveGraphTask
implements GraphTask, PotentialCyclicEdgeProducer
{
private DependencyGraphBuilder builder;
private int resolvedCount = 0;

private VersionedReference toVersionedReference( DependencyGraphNode node )
{
VersionedReference ref = new VersionedReference();
ref.setGroupId( node.getArtifact().getGroupId() );
ref.setArtifactId( node.getArtifact().getArtifactId() );
ref.setVersion( node.getArtifact().getVersion() );

return ref;
}

public void executeTask( DependencyGraph graph )
{
resolvedCount = 0;
VersionedReference rootRef = toVersionedReference( graph.getRootNode() );

if ( !graph.getRootNode().isResolved() )
{
builder.resolveNode( graph, graph.getRootNode(), rootRef );
resolvedCount++;
}

boolean done = false;

while ( !done )
{
DependencyGraphNode node = findUnresolvedNode( graph );
if ( node == null )
{
done = true;
break;
}

VersionedReference otherRef = toVersionedReference( node );

builder.resolveNode( graph, node, otherRef );
resolvedCount++;
}
}

private DependencyGraphNode findUnresolvedNode( DependencyGraph graph )
{
return (DependencyGraphNode) CollectionUtils
.find( graph.getNodes(), UnresolvedGraphNodePredicate.getInstance() );
}

public DependencyGraphBuilder getBuilder()
{
return builder;
}

public void setBuilder( DependencyGraphBuilder graphBuilder )
{
this.builder = graphBuilder;
}

public String getTaskId()
{
return "resolve-graph";
}

public int getResolvedCount()
{
return resolvedCount;
}
}

+ 0
- 48
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/UpdateScopesTask.java View File

@@ -1,48 +0,0 @@
package org.apache.maven.archiva.dependency.graph.tasks;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.maven.archiva.dependency.graph.DependencyGraph;
import org.apache.maven.archiva.dependency.graph.GraphTask;
import org.apache.maven.archiva.dependency.graph.GraphTaskException;
import org.apache.maven.archiva.dependency.graph.walk.DependencyGraphWalker;
import org.apache.maven.archiva.dependency.graph.walk.WalkDepthFirstSearch;

/**
* Update the scopes of the edges to what their parent node says.
*
* @version $Id$
*/
public class UpdateScopesTask
implements GraphTask
{
public void executeTask( DependencyGraph graph )
throws GraphTaskException
{
DependencyGraphWalker walker = new WalkDepthFirstSearch();
UpdateScopesVisitor updateScopes = new UpdateScopesVisitor();
walker.visit( graph, updateScopes );
}

public String getTaskId()
{
return "update-scopes";
}
}

+ 0
- 81
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/tasks/UpdateScopesVisitor.java View File

@@ -1,81 +0,0 @@
package org.apache.maven.archiva.dependency.graph.tasks;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.commons.collections.Predicate;
import org.apache.maven.archiva.dependency.graph.DependencyGraph;
import org.apache.maven.archiva.dependency.graph.DependencyGraphEdge;
import org.apache.maven.archiva.dependency.graph.functors.EdgeFromPredicate;
import org.apache.maven.archiva.dependency.graph.walk.BaseVisitor;
import org.apache.maven.archiva.dependency.graph.walk.DependencyGraphVisitor;
import org.apache.maven.archiva.model.DependencyScope;

import java.util.Stack;

/**
* UpdateScopesVisitor
*
* @version $Id$
*/
public class UpdateScopesVisitor
extends BaseVisitor
implements DependencyGraphVisitor
{
private Stack<String> scopeStack;

private Predicate rootEdgePredicate;

public UpdateScopesVisitor()
{
scopeStack = new Stack<String>();
// Default setting.
scopeStack.add( DependencyScope.COMPILE );
}

public void discoverGraph( DependencyGraph graph )
{
super.discoverGraph( graph );
rootEdgePredicate = new EdgeFromPredicate( graph.getRootNode() );
}

public void discoverEdge( DependencyGraphEdge edge )
{
super.discoverEdge( edge );
String scope = edge.getScope();

if ( !rootEdgePredicate.evaluate( edge ) )
{
// Not a root edge. Set the scope.
scope = (String) scopeStack.peek();
edge.setScope( scope );
}
// Push the scope used onto the stack.
scopeStack.push( scope );
}

public void finishEdge( DependencyGraphEdge edge )
{
super.finishEdge( edge );

scopeStack.pop();
}
}

+ 0
- 72
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/walk/BaseVisitor.java View File

@@ -1,72 +0,0 @@
package org.apache.maven.archiva.dependency.graph.walk;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.maven.archiva.dependency.graph.DependencyGraph;
import org.apache.maven.archiva.dependency.graph.DependencyGraphEdge;
import org.apache.maven.archiva.dependency.graph.DependencyGraphNode;

/**
* The Baseline Visitor.
*
* @version $Id$
*/
public class BaseVisitor
implements DependencyGraphVisitor
{
private static DependencyGraphVisitor INSTANCE = new BaseVisitor();
protected DependencyGraph graph;

public static DependencyGraphVisitor getInstance()
{
return INSTANCE;
}

public void discoverEdge( DependencyGraphEdge edge )
{
/* do nothing */
}

public void discoverGraph( DependencyGraph graph )
{
this.graph = graph;
}

public void discoverNode( DependencyGraphNode node )
{
/* do nothing */
}

public void finishEdge( DependencyGraphEdge edge )
{
/* do nothing */
}

public void finishGraph( DependencyGraph graph )
{
/* do nothing */
}

public void finishNode( DependencyGraphNode node )
{
/* do nothing */
}
}

+ 0
- 75
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/walk/DependencyGraphVisitor.java View File

@@ -1,75 +0,0 @@
package org.apache.maven.archiva.dependency.graph.walk;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.maven.archiva.dependency.graph.DependencyGraph;
import org.apache.maven.archiva.dependency.graph.DependencyGraphEdge;
import org.apache.maven.archiva.dependency.graph.DependencyGraphNode;

/**
* Interface for progress during search.
*
* @version $Id$
*/
public interface DependencyGraphVisitor
{
/**
* Called once, for when the graph itself is discovered.
*
* @param graph the graph that was discovered.
*/
public void discoverGraph( DependencyGraph graph );

/**
* Called for each node, when that node is visited.
*
* @param node the node that is being visited.
*/
public void discoverNode( DependencyGraphNode node );

/**
* Called for each edge, when that edge is visited.
*
* @param edge the edge that is being visited.
*/
public void discoverEdge( DependencyGraphEdge edge );

/**
* Called for each edge, when that edge has been fully visited.
*
* @param edge the edge that was finished being visited.
*/
public void finishEdge( DependencyGraphEdge edge );

/**
* Called for each node, when the node has been fully visited.
*
* @param node the node that was finished being visited.
*/
public void finishNode( DependencyGraphNode node );

/**
* Called once, for when the graph is finished being visited.
*
* @param graph the graph that finished being visited.
*/
public void finishGraph( DependencyGraph graph );

}

+ 0
- 88
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/walk/DependencyGraphWalker.java View File

@@ -1,88 +0,0 @@
package org.apache.maven.archiva.dependency.graph.walk;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.commons.collections.Predicate;
import org.apache.maven.archiva.dependency.graph.DependencyGraph;
import org.apache.maven.archiva.dependency.graph.DependencyGraphNode;
import org.apache.maven.archiva.model.ArtifactReference;

/**
* Walk nodes of the {@link DependencyGraph}.
*
* @version $Id$
*/
public interface DependencyGraphWalker
{
/**
* A {@link #getNodeVisitState(ArtifactReference)} for a node not yet seen in the walker.
*/
public static final Integer UNSEEN = new Integer( 0 );

/**
* A {@link #getNodeVisitState(ArtifactReference)} for a node that is actively being processed,
* but not yet finished processing.
*/
public static final Integer PROCESSING = new Integer( 1 );

/**
* A {@link #getNodeVisitState(ArtifactReference)} for a node that has been seen, and fully processed.
*/
public static final Integer SEEN = new Integer( 2 );

/**
* For a provided node, get the current node visit state.
*
* @param node the node that you are interested in.
* @return the state of that node. (Can be {@link #UNSEEN}, {@link #PROCESSING}, or {@link #SEEN} )
*/
public Integer getNodeVisitState( ArtifactReference artifact );

/**
* Get the predicate used to determine if the walker should traverse an edge (or not).
*
* @return the Predicate that returns true for edges that should be traversed.
*/
public Predicate getEdgePredicate();

/**
* Set the predicate used for edge traversal
*
* @param edgePredicate the Predicate that returns true for edges that should be traversed.
*/
public void setEdgePredicate( Predicate edgePredicate );

/**
* Visit every node and edge in the graph from the startNode.
*
* @param graph the graph to visit.
* @param startNode the node to start the visit on.
* @param visitor the visitor object to use during this visit.
*/
public void visit( DependencyGraph graph, DependencyGraphNode startNode, DependencyGraphVisitor visitor );

/**
* Visit every node and edge in the entire graph.
*
* @param graph the graph to visit.
* @param visitor the visitor object to use during this visit.
*/
public void visit( DependencyGraph graph, DependencyGraphVisitor visitor );
}

+ 0
- 148
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/walk/WalkBreadthFirstSearch.java View File

@@ -1,148 +0,0 @@
package org.apache.maven.archiva.dependency.graph.walk;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.collections.Predicate;
import org.apache.commons.collections.functors.NotPredicate;
import org.apache.maven.archiva.dependency.graph.DependencyGraph;
import org.apache.maven.archiva.dependency.graph.DependencyGraphEdge;
import org.apache.maven.archiva.dependency.graph.DependencyGraphNode;
import org.apache.maven.archiva.dependency.graph.functors.EdgeDisabledPredicate;
import org.apache.maven.archiva.model.ArtifactReference;

/**
* WalkBreadthFirstSearch
*
* @version $Id$
*/
public class WalkBreadthFirstSearch
implements DependencyGraphWalker
{
private Map<ArtifactReference, Integer> nodeVisitStates = new HashMap<ArtifactReference, Integer>();

private Predicate edgePredicate;

public WalkBreadthFirstSearch()
{
this.edgePredicate = NotPredicate.getInstance( new EdgeDisabledPredicate() );
}

public Predicate getEdgePredicate()
{
return this.edgePredicate;
}

public void setEdgePredicate( Predicate edgePredicate )
{
this.edgePredicate = edgePredicate;
}

public Integer getNodeVisitState( DependencyGraphNode node )
{
return (Integer) nodeVisitStates.get( node.getArtifact() );
}

public Integer getNodeVisitState( ArtifactReference artifact )
{
return (Integer) nodeVisitStates.get( artifact );
}

public void setNodeVisitState( DependencyGraphNode node, Integer state )
{
this.nodeVisitStates.put( node.getArtifact(), state );
}

public void setNodeVisitState( ArtifactReference artifact, Integer state )
{
this.nodeVisitStates.put( artifact, state );
}

private void visitEdge( DependencyGraph graph, DependencyGraphEdge e, DependencyGraphVisitor visitor )
{
visitor.discoverEdge( e );

DependencyGraphNode node = graph.getNode( e.getNodeTo() );

if ( getNodeVisitState( node ) == UNSEEN )
{
setNodeVisitState( node, PROCESSING );
}

visitor.finishEdge( e );
}

private void visitNode( DependencyGraph graph, DependencyGraphNode node, DependencyGraphVisitor visitor )
{
setNodeVisitState( node, PROCESSING );

visitor.discoverNode( node );

// First dive down edges.
for ( DependencyGraphEdge e : graph.getEdgesFrom( node ) )
{
if ( this.edgePredicate.evaluate( e ) )
{
visitEdge( graph, e, visitor );
}
}

// Next move down edges.
for ( DependencyGraphEdge e : graph.getEdgesFrom( node ) )
{
if ( this.edgePredicate.evaluate( e ) )
{
DependencyGraphNode nodeTo = graph.getNode( e.getNodeTo() );
Integer state = getNodeVisitState( nodeTo );
if ( ( state == UNSEEN ) || ( state == PROCESSING ) )
{
visitNode( graph, nodeTo, visitor );
}
}
}

visitor.finishNode( node );

setNodeVisitState( node, SEEN );
}

public void visit( DependencyGraph graph, DependencyGraphVisitor visitor )
{
visit( graph, graph.getRootNode(), visitor );
}

public void visit( DependencyGraph graph, DependencyGraphNode startNode, DependencyGraphVisitor visitor )
{
nodeVisitStates.clear();

for ( DependencyGraphNode node : graph.getNodes() )
{
setNodeVisitState( node, UNSEEN );
}

visitor.discoverGraph( graph );

visitNode( graph, startNode, visitor );

visitor.finishGraph( graph );
}
}

+ 0
- 140
archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/walk/WalkDepthFirstSearch.java View File

@@ -1,140 +0,0 @@
package org.apache.maven.archiva.dependency.graph.walk;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.collections.Predicate;
import org.apache.commons.collections.functors.NotPredicate;
import org.apache.maven.archiva.dependency.graph.DependencyGraph;
import org.apache.maven.archiva.dependency.graph.DependencyGraphEdge;
import org.apache.maven.archiva.dependency.graph.DependencyGraphNode;
import org.apache.maven.archiva.dependency.graph.functors.EdgeDisabledPredicate;
import org.apache.maven.archiva.model.ArtifactReference;

/**
* Perform a walk of the graph using the DepthFirstSearch algorithm.
*
* NOTE: Default edgePredicate is to NOT traverse disabled edges.
*
* @version $Id$
*/
public class WalkDepthFirstSearch
implements DependencyGraphWalker
{
private Map<ArtifactReference, Integer> nodeVisitStates = new HashMap<ArtifactReference, Integer>();

private Predicate edgePredicate;

public WalkDepthFirstSearch()
{
this.edgePredicate = NotPredicate.getInstance( new EdgeDisabledPredicate() );
}

public Predicate getEdgePredicate()
{
return this.edgePredicate;
}

public void setEdgePredicate( Predicate edgePredicate )
{
this.edgePredicate = edgePredicate;
}

public Integer getNodeVisitState( DependencyGraphNode node )
{
if ( node == null )
{
return SEEN;
}

return (Integer) nodeVisitStates.get( node.getArtifact() );
}

public Integer getNodeVisitState( ArtifactReference artifact )
{
return (Integer) nodeVisitStates.get( artifact );
}

public void setNodeVisitState( DependencyGraphNode node, Integer state )
{
this.nodeVisitStates.put( node.getArtifact(), state );
}

public void setNodeVisitState( ArtifactReference artifact, Integer state )
{
this.nodeVisitStates.put( artifact, state );
}

private void visitEdge( DependencyGraph graph, DependencyGraphEdge e, DependencyGraphVisitor visitor )
{
visitor.discoverEdge( e );

DependencyGraphNode node = graph.getNode( e.getNodeTo() );

if ( getNodeVisitState( node ) == UNSEEN )
{
visitNode( graph, node, visitor );
}

visitor.finishEdge( e );
}

private void visitNode( DependencyGraph graph, DependencyGraphNode node, DependencyGraphVisitor visitor )
{
setNodeVisitState( node, PROCESSING );

visitor.discoverNode( node );

for ( DependencyGraphEdge e : graph.getEdgesFrom( node ) )
{
if ( this.edgePredicate.evaluate( e ) )
{
visitEdge( graph, e, visitor );
}
}

visitor.finishNode( node );

setNodeVisitState( node, SEEN );
}

public void visit( DependencyGraph graph, DependencyGraphVisitor visitor )
{
visit( graph, graph.getRootNode(), visitor );
}

public void visit( DependencyGraph graph, DependencyGraphNode startNode, DependencyGraphVisitor visitor )
{
nodeVisitStates.clear();

for ( DependencyGraphNode node : graph.getNodes() )
{
setNodeVisitState( node, UNSEEN );
}

visitor.discoverGraph( graph );

visitNode( graph, startNode, visitor );

visitor.finishGraph( graph );
}
}

+ 0
- 373
archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/AbstractDependencyGraphFactoryTestCase.java View File

@@ -1,373 +0,0 @@
package org.apache.maven.archiva.dependency.graph;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.Predicate;
import org.apache.commons.collections.functors.AndPredicate;
import org.apache.commons.collections.functors.NotPredicate;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.archiva.dependency.graph.functors.EdgeExactScopePredicate;
import org.apache.maven.archiva.dependency.graph.functors.EdgeFromPredicate;
import org.apache.maven.archiva.dependency.graph.functors.NodeFromParentPredicate;
import org.apache.maven.archiva.dependency.graph.functors.NodePredicate;
import org.apache.maven.archiva.dependency.graph.functors.ToKeyTransformer;
import org.apache.maven.archiva.model.ArchivaProjectModel;
import org.apache.maven.archiva.model.ArtifactReference;
import org.apache.maven.archiva.model.Dependency;
import org.apache.maven.archiva.model.VersionedReference;
import org.codehaus.plexus.spring.PlexusInSpringTestCase;

/**
* AbstractDependencyGraphFactoryTestCase
*
* @version $Id$
*/
public abstract class AbstractDependencyGraphFactoryTestCase
extends PlexusInSpringTestCase
{
public class ExpectedEdge
{
public String from;

public String to;

public ExpectedEdge( String from, String to )
{
this.from = from;
this.to = to;
}
}

public class GraphEdgePredicate
implements Predicate
{
private String edgeFrom;

private String edgeTo;

public GraphEdgePredicate( String edgeFrom, String edgeTo )
{
this.edgeFrom = edgeFrom;
this.edgeTo = edgeTo;
}

public boolean evaluate( Object object )
{
boolean satisfies = false;

if ( object instanceof DependencyGraphEdge )
{
DependencyGraphEdge edge = (DependencyGraphEdge) object;
String actualFrom = ArtifactReference.toKey( edge.getNodeFrom() );
String actualTo = ArtifactReference.toKey( edge.getNodeTo() );

satisfies = ( StringUtils.equals( edgeFrom, actualFrom ) && StringUtils.equals( edgeTo, actualTo ) );
}

return satisfies;
}
}

@SuppressWarnings("unchecked")
protected void assertDirectNodes( DependencyGraph graph, List<DependencyGraphNode> expectedNodes, String scope )
{
DependencyGraphNode rootNode = graph.getRootNode();
List<DependencyGraphEdge> rootEdges = graph.getEdgesFrom( rootNode );
List<DependencyGraphEdge> actualEdges = new ArrayList<DependencyGraphEdge>();

Predicate directDep = NotPredicate.getInstance( new NodeFromParentPredicate() );
Predicate scopedDirectDeps = AndPredicate.getInstance( new EdgeExactScopePredicate( scope ), directDep );
CollectionUtils.select( rootEdges, scopedDirectDeps, actualEdges );
// CollectionUtils.select( rootEdges, new EdgeExactScopePredicate( scope ), actualEdges );

if ( expectedNodes.size() != actualEdges.size() )
{
StringBuffer sb = new StringBuffer();

sb.append( "Direct node.count with <" ).append( scope ).append( "> edges from [" );
sb.append( DependencyGraphKeys.toKey( rootNode.getArtifact() ) ).append( "]" ).append( " expected:<" );
sb.append( expectedNodes.size() ).append( "> but was:<" );
sb.append( actualEdges.size() ).append( ">" );

CollectionUtils.transform( actualEdges, new ToKeyTransformer() );

Collection<String> missingActualKeys = CollectionUtils.subtract( actualEdges, expectedNodes );
for ( String key : missingActualKeys )
{
sb.append( "\n (Extra Actual) " ).append( key );
}

Collection<String> missingExpectedKeys = CollectionUtils.subtract( expectedNodes, actualEdges );
for ( String key : missingExpectedKeys )
{
sb.append( "\n (Extra Expected) " ).append( key );
}

fail( sb.toString() );
}

for ( DependencyGraphEdge edge : actualEdges )
{
String actualKey = DependencyGraphKeys.toKey( edge.getNodeTo() );
assertTrue( "Direct <" + scope + "> node To [" + actualKey + "] exists in expectedNodes.", expectedNodes
.contains( actualKey ) );
}
}

protected void assertEdges( DependencyGraph graph, List<ExpectedEdge> expectedEdges )
{
assertNotNull( "Graph.edges should never be null.", graph.getEdges() );
assertEquals( "Graph.edges.size()", expectedEdges.size(), graph.getEdges().size() );

for ( ExpectedEdge expectedEdge : expectedEdges )
{
Predicate edgePredicate = new GraphEdgePredicate( expectedEdge.from, expectedEdge.to );

DependencyGraphEdge edge = (DependencyGraphEdge) CollectionUtils.find( graph.getEdges(), edgePredicate );
if ( edge == null )
{
fail( "Unable to find expected edge from:<" + expectedEdge.from + "> to:<" + expectedEdge.to + ">" );
}
}
}

@SuppressWarnings("unchecked")
protected void assertGraph( DependencyGraph graph, String rootRefKey, List expectedNodeKeys )
{
assertNotNull( "Graph.nodes should never be null.", graph.getNodes() );
assertTrue( "Graph.nodes.size() should always be 1 or better.", graph.getNodes().size() >= 1 );

ArtifactReference rootRef = graph.getRootNode().getArtifact();
StringBuffer actualRootRef = new StringBuffer();
actualRootRef.append( rootRef.getGroupId() ).append( ":" );
actualRootRef.append( rootRef.getArtifactId() ).append( ":" );
actualRootRef.append( rootRef.getVersion() );

assertEquals( "Graph.root", rootRefKey, actualRootRef.toString() );

List<DependencyGraphNode> actualNodes = new ArrayList<DependencyGraphNode>();

Predicate notRootNode = NotPredicate.getInstance( new NodePredicate( graph.getRootNode() ) );
CollectionUtils.select( graph.getNodes(), notRootNode, actualNodes );

boolean fail = false;
StringBuffer sb = new StringBuffer();
if ( expectedNodeKeys.size() != actualNodes.size() )
{
sb.append( "node.count expected:<" );
sb.append( expectedNodeKeys.size() ).append( "> but was:<" );
sb.append( actualNodes.size() ).append( ">" );
fail = true;
}

CollectionUtils.transform( actualNodes, new ToKeyTransformer() );

Collection<String> missingActualKeys = CollectionUtils.subtract( actualNodes, expectedNodeKeys );
for ( String key : missingActualKeys )
{
sb.append( "\n (Extra Actual) " ).append( key );
fail = true;
}

Collection<String> missingExpectedKeys = CollectionUtils.subtract( expectedNodeKeys, actualNodes );
for ( String key : missingExpectedKeys )
{
sb.append( "\n (Extra Expected) " ).append( key );
fail = true;
}

if( fail )
{
fail( sb.toString() );
}

/*
it = actualNodes.iterator();
while ( it.hasNext() )
{
DependencyGraphNode node = (DependencyGraphNode) it.next();
assertNotNull( "Artifact reference in node should not be null.", node.getArtifact() );
String key = ArtifactReference.toKey( node.getArtifact() );
assertTrue( "Artifact reference [" + key + "] should be in expectedNodeKeys.", expectedNodeKeys
.contains( key ) );
}
*/
}

@SuppressWarnings("unchecked")
protected void assertNodes( DependencyGraph graph, List<String> expectedNodeKeys )
{
assertNotNull( "Graph.nodes should never be null.", graph.getNodes() );
assertTrue( "Graph.nodes.size() should always be 1 or better.", graph.getNodes().size() >= 1 );
// assertEquals( "Graph.nodes.size()", expectedNodeKeys.size(), graph.getNodes().size() );

List<DependencyGraphNode> actualNodes = new ArrayList<DependencyGraphNode>();
actualNodes.addAll( graph.getNodes() );

if ( expectedNodeKeys.size() != actualNodes.size() )
{
StringBuffer sb = new StringBuffer();

sb.append( "node.count expected:<" );
sb.append( expectedNodeKeys.size() ).append( "> but was:<" );
sb.append( actualNodes.size() ).append( ">" );

CollectionUtils.transform( actualNodes, new ToKeyTransformer() );

Collection<String> missingActualKeys = CollectionUtils.subtract( actualNodes, expectedNodeKeys );
for ( String key : missingActualKeys )
{
sb.append( "\n (Extra Actual) " ).append( key );
}

Collection<String> missingExpectedKeys = CollectionUtils.subtract( expectedNodeKeys, actualNodes );
for ( String key : missingExpectedKeys )
{
sb.append( "\n (Extra Expected) " ).append( key );
}

fail( sb.toString() );
}

for ( DependencyGraphNode node : graph.getNodes() )
{
assertNotNull( "Artifact reference in node should not be null.", node.getArtifact() );
String key = ArtifactReference.toKey( node.getArtifact() );
assertTrue( "Artifact reference [" + key + "] should be in expectedNodeKeys.", expectedNodeKeys
.contains( key ) );
}
}

protected void assertRootNode( DependencyGraph graph, String expectedKey )
{
DependencyGraphNode node = graph.getRootNode();

String actualKey = DependencyGraphKeys.toKey( node.getArtifact() );
assertEquals( "Root Node", expectedKey, actualKey );
}

@SuppressWarnings("unchecked")
protected void assertTransientNodes( DependencyGraph graph, List<DependencyGraphNode> expectedNodes, String scope )
{
// Gather up the transient nodes from the DependencyGraph.
ArrayList<DependencyGraphEdge> actualEdges = new ArrayList<DependencyGraphEdge>();

DependencyGraphNode rootNode = graph.getRootNode();

Predicate transientDep = NotPredicate.getInstance( new EdgeFromPredicate( rootNode.getArtifact() ) );
Predicate edgeByExactScope = new EdgeExactScopePredicate( scope );
Predicate transitiveEdgesByScopePredicate = AndPredicate.getInstance( transientDep, edgeByExactScope );

CollectionUtils.select( graph.getEdges(), transitiveEdgesByScopePredicate, actualEdges );

if ( expectedNodes.size() != actualEdges.size() )
{
StringBuffer sb = new StringBuffer();

sb.append( "Transient node.count with <" ).append( scope ).append( "> edges from [" );
sb.append( DependencyGraphKeys.toKey( rootNode.getArtifact() ) ).append( "]" ).append( " expected:<" );
sb.append( expectedNodes.size() ).append( "> but was:<" );
sb.append( actualEdges.size() ).append( ">" );

CollectionUtils.transform( actualEdges, new ToKeyTransformer() );

Collection<DependencyGraphNode> missingActualKeys = CollectionUtils.subtract( actualEdges, expectedNodes );
for ( DependencyGraphNode key : missingActualKeys )
{
sb.append( "\n (Extra Actual) " ).append( key );
}

Collection<DependencyGraphNode> missingExpectedKeys = CollectionUtils.subtract( expectedNodes, actualEdges );
for ( DependencyGraphNode key : missingExpectedKeys )
{
sb.append( "\n (Extra Expected) " ).append( key );
}

fail( sb.toString() );
}

for ( DependencyGraphEdge edge : actualEdges )
{
String actualKey = DependencyGraphKeys.toKey( edge.getNodeTo() );
assertTrue( "Transient Node To [" + actualKey + "] exists in expectedNodes.", expectedNodes
.contains( actualKey ) );
}
}

protected Dependency toDependency( String key )
{
String parts[] = StringUtils.splitPreserveAllTokens( key, ':' );

assertEquals( "Dependency key [" + key + "] should be 5 parts.", 5, parts.length );

Dependency dep = new Dependency();

dep.setGroupId( parts[0] );
dep.setArtifactId( parts[1] );
dep.setVersion( parts[2] );
dep.setClassifier( parts[3] );
dep.setType( parts[4] );

return dep;
}

protected ArchivaProjectModel toModel( String key, Dependency deps[] )
{
String parts[] = StringUtils.splitPreserveAllTokens( key, ':' );

assertEquals( "Dependency key [" + key + "] should be 3 parts.", 3, parts.length );

ArchivaProjectModel model = new ArchivaProjectModel();
model.setGroupId( parts[0] );
model.setArtifactId( parts[1] );
model.setVersion( parts[2] );
model.setOrigin( "testcase" );
model.setPackaging( "jar" );

if ( deps != null )
{
for ( int i = 0; i < deps.length; i++ )
{
Dependency dep = deps[i];
model.addDependency( dep );
}
}

return model;
}

protected VersionedReference toVersionedReference( String key )
{
String parts[] = StringUtils.splitPreserveAllTokens( key, ':' );
assertEquals( "Versioned Reference [" + key + "] part count.", 3, parts.length );

VersionedReference ref = new VersionedReference();
ref.setGroupId( parts[0] );
ref.setArtifactId( parts[1] );
ref.setVersion( parts[2] );
return ref;
}
}

+ 0
- 172
archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/AbstractMemoryRepository.java View File

@@ -1,172 +0,0 @@
package org.apache.maven.archiva.dependency.graph;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.apache.maven.archiva.model.ArchivaProjectModel;
import org.apache.maven.archiva.model.Dependency;
import org.apache.maven.archiva.model.Exclusion;
import org.apache.maven.archiva.model.Keys;
import org.apache.maven.archiva.model.VersionedReference;

/**
* AbstractMemoryRepository
*
* @version $Id$
*/
public abstract class AbstractMemoryRepository
implements MemoryRepository
{
private Map<String,ArchivaProjectModel> modelMap = new HashMap<String, ArchivaProjectModel>();

public AbstractMemoryRepository()
{
initialize();
}

public void addModel( ArchivaProjectModel model )
{
String key = Keys.toKey( model );
modelMap.put( key, model );
}

public ArchivaProjectModel getProjectModel( String groupId, String artifactId, String version )
{
String key = Keys.toKey( groupId, artifactId, version );

return (ArchivaProjectModel) modelMap.get( key );
}

public abstract void initialize();

protected void addExclusion( Dependency dependency, String key )
{
String parts[] = StringUtils.splitPreserveAllTokens( key, ':' );

if ( parts.length != 2 )
{
throw new IllegalArgumentException( "Exclusion key [" + key + "] should be 2 parts. (detected "
+ parts.length + " instead)" );
}

Exclusion exclusion = new Exclusion();
exclusion.setGroupId( parts[0] );
exclusion.setArtifactId( parts[1] );

dependency.addExclusion( exclusion );
}

protected Dependency toDependency( String key )
{
String parts[] = StringUtils.splitPreserveAllTokens( key, ':' );

if ( parts.length != 5 )
{
throw new IllegalArgumentException( "Dependency key [" + key + "] should be 5 parts. (detected "
+ parts.length + " instead)" );
}

Dependency dep = new Dependency();

dep.setGroupId( parts[0] );
dep.setArtifactId( parts[1] );
dep.setVersion( parts[2] );
dep.setClassifier( parts[3] );
dep.setType( parts[4] );

return dep;
}

protected Dependency toDependency( String key, String scope )
{
Dependency dependency = toDependency( key );
dependency.setScope( scope );

return dependency;
}

protected ArchivaProjectModel toModel( String key )
{
return toModel( key, Collections.<Dependency>emptyList() );
}

protected ArchivaProjectModel toModel( String key, Dependency[] deps )
{
List<Dependency> depList = new ArrayList<Dependency>();

if ( deps != null )
{
depList.addAll( Arrays.asList( deps ) );
}

return toModel( key, depList );
}

protected ArchivaProjectModel toModel( String key, List<Dependency> deps )
{
String parts[] = StringUtils.splitPreserveAllTokens( key, ':' );

if ( parts.length != 3 )
{
throw new IllegalArgumentException( "Project/Model key [" + key + "] should be 3 parts. (detected "
+ parts.length + " instead)" );
}

ArchivaProjectModel model = new ArchivaProjectModel();
model.setGroupId( parts[0] );
model.setArtifactId( parts[1] );
model.setVersion( parts[2] );
model.setOrigin( "testcase" );
model.setPackaging( "jar" );

for ( Dependency dep : deps )
{
model.addDependency( dep );
}

return model;
}

protected VersionedReference toParent( String key )
{
String parts[] = StringUtils.splitPreserveAllTokens( key, ':' );

if ( parts.length != 3 )
{
throw new IllegalArgumentException( "Parent key [" + key + "] should be 3 parts. (detected " + parts.length
+ " instead)" );
}

VersionedReference ref = new VersionedReference();
ref.setGroupId( parts[0] );
ref.setArtifactId( parts[1] );
ref.setVersion( parts[2] );

return ref;
}

}

+ 0
- 50
archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/AllTests.java View File

@@ -1,50 +0,0 @@
package org.apache.maven.archiva.dependency.graph;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import junit.framework.Test;
import junit.framework.TestSuite;

/**
* Utility class to aide IDE developers.
*
* @version $Id$
*/
public class AllTests
{

public static Test suite()
{
TestSuite suite = new TestSuite( "Test for org.apache.maven.archiva.repository.project.dependencies" );
//$JUnit-BEGIN$
suite.addTestSuite( ArchivaWebappDependencyGraphTest.class );
suite.addTestSuite( GraphvizDotTool.class );
suite.addTestSuite( DepManDeepVersionDependencyGraphTest.class );
suite.addTestSuite( SimpleDependencyGraphTest.class );
// suite.addTestSuite( MavenProjectInfoReportsPluginDependencyGraphTest.class );
suite.addTestSuite( ArchivaCommonDependencyGraphTest.class );
suite.addTestSuite( WagonManagerDependencyGraphTest.class );
suite.addTestSuite( ContinuumStoreDependencyGraphTest.class );
suite.addTestSuite( ArchivaXmlToolsDependencyGraphTest.class );
//$JUnit-END$
return suite;
}

}

+ 0
- 77
archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/ArchivaCommonDependencyGraphTest.java View File

@@ -1,77 +0,0 @@
package org.apache.maven.archiva.dependency.graph;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.maven.archiva.dependency.DependencyGraphFactory;
import org.apache.maven.archiva.model.DependencyScope;
import org.apache.maven.archiva.model.VersionedReference;

import java.util.ArrayList;
import java.util.List;

/**
* ArchivaCommonDependencyGraphTest
*
* DependencyGraphTest for testing <code>org.apache.maven.archiva:archiva-common:1.0-alpha-2-SNAPSHOT</code>
*
* Generated by <code>archivadev:generate-dependency-tests</code> plugin
* @version $Id$
*/
public class ArchivaCommonDependencyGraphTest
extends AbstractDependencyGraphFactoryTestCase
{
public void testResolvedDepsToNodes()
throws GraphTaskException
{
MemoryRepositoryDependencyGraphBuilder graphBuilder =
new MemoryRepositoryDependencyGraphBuilder();
MemoryRepository repository = new ArchivaCommonMemoryRepository();
graphBuilder.setMemoryRepository( repository );

// Create the factory, and add the test resolver.
DependencyGraphFactory factory = new DependencyGraphFactory();
factory.setGraphBuilder( graphBuilder );
factory.setDesiredScope( DependencyScope.TEST );

// Get the model to resolve from
VersionedReference rootRef = toVersionedReference( "org.apache.maven.archiva:archiva-common:1.0-alpha-2-SNAPSHOT");

// Perform the resolution.
DependencyGraph graph = factory.getGraph( rootRef );

// Test the results.
assertNotNull( "Graph shouldn't be null.", graph );

String expectedRootRef = "org.apache.maven.archiva:archiva-common:1.0-alpha-2-SNAPSHOT";
List<String> expectedNodes = new ArrayList<String>();

// Check for all nodes, regardless of scope.
expectedNodes.clear();
expectedNodes.add( "commons-lang:commons-lang:2.2::jar" );
expectedNodes.add( "junit:junit:3.8.1::jar" );
expectedNodes.add( "org.codehaus.plexus:plexus-classworlds:1.2-alpha-7::jar" );
expectedNodes.add( "org.codehaus.plexus:plexus-component-api:1.0-alpha-22::jar" );
expectedNodes.add( "org.codehaus.plexus:plexus-container-default:1.0-alpha-22::jar" );
expectedNodes.add( "org.codehaus.plexus:plexus-utils:1.4::jar" );

assertGraph( graph, expectedRootRef, expectedNodes );
}

}

+ 0
- 3469
archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/ArchivaCommonMemoryRepository.java
File diff suppressed because it is too large
View File


+ 0
- 200
archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/ArchivaWebappDependencyGraphTest.java View File

@@ -1,200 +0,0 @@
package org.apache.maven.archiva.dependency.graph;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.maven.archiva.dependency.DependencyGraphFactory;
import org.apache.maven.archiva.model.DependencyScope;
import org.apache.maven.archiva.model.VersionedReference;

import java.util.ArrayList;
import java.util.List;

/**
* ArchivaWebappDependencyGraphTest
*
* DependencyGraphTest for testing <code>org.apache.maven.archiva:archiva-webapp:1.0-alpha-2-SNAPSHOT</code>
*
* Generated by <code>archivadev:generate-dependency-tests</code> plugin
* @version $Id$
*/
public class ArchivaWebappDependencyGraphTest
extends AbstractDependencyGraphFactoryTestCase
{
public void testResolvedDepsToNodes()
throws GraphTaskException
{
MemoryRepositoryDependencyGraphBuilder graphBuilder =
new MemoryRepositoryDependencyGraphBuilder();
MemoryRepository repository = new ArchivaWebappMemoryRepository();
graphBuilder.setMemoryRepository( repository );

// Create the factory, and add the test resolver.
DependencyGraphFactory factory = new DependencyGraphFactory();
factory.setGraphBuilder( graphBuilder );
factory.setDesiredScope( DependencyScope.TEST );

// Get the model to resolve from
VersionedReference rootRef = toVersionedReference( "org.apache.maven.archiva:archiva-webapp:1.0-alpha-2-SNAPSHOT");

// Perform the resolution.
DependencyGraph graph = factory.getGraph( rootRef );

// Test the results.
assertNotNull( "Graph shouldn't be null.", graph );

String expectedRootRef = "org.apache.maven.archiva:archiva-webapp:1.0-alpha-2-SNAPSHOT";
List<String> expectedNodes = new ArrayList<String>();

// Check for all nodes, regardless of scope.
expectedNodes.clear();
expectedNodes.add( "ant:ant-optional:1.5.1::jar" );
expectedNodes.add( "backport-util-concurrent:backport-util-concurrent:3.0::jar" );
expectedNodes.add( "classworlds:classworlds:1.1::jar" );
expectedNodes.add( "commons-beanutils:commons-beanutils:1.7.0::jar" );
expectedNodes.add( "commons-beanutils:commons-beanutils-bean-collections:1.7.0::jar" );
expectedNodes.add( "commons-codec:commons-codec:1.3::jar" );
expectedNodes.add( "commons-collections:commons-collections:3.2::jar" );
expectedNodes.add( "commons-configuration:commons-configuration:1.3::jar" );
expectedNodes.add( "commons-digester:commons-digester:1.6::jar" );
expectedNodes.add( "commons-io:commons-io:1.2::jar" );
expectedNodes.add( "commons-jxpath:commons-jxpath:1.2::jar" );
expectedNodes.add( "commons-lang:commons-lang:2.2::jar" );
expectedNodes.add( "commons-logging:commons-logging:1.0.4::jar" );
expectedNodes.add( "commons-logging:commons-logging-api:1.0.4::jar" );
expectedNodes.add( "dom4j:dom4j:1.6.1::jar" );
expectedNodes.add( "freemarker:freemarker:2.3.4::jar" );
expectedNodes.add( "geronimo-spec:geronimo-spec-jta:1.0.1B-rc2::jar" );
expectedNodes.add( "it.could:webdav:0.4::jar" );
expectedNodes.add( "javax.activation:activation:1.1::jar" );
expectedNodes.add( "javax.jdo:jdo2-api:2.0::jar" );
expectedNodes.add( "javax.mail:mail:1.4::jar" );
expectedNodes.add( "javax.resource:connector:1.0::jar" );
expectedNodes.add( "javax.servlet:jsp-api:2.0::jar" );
expectedNodes.add( "javax.servlet:jstl:1.1.2::jar" );
expectedNodes.add( "javax.servlet:servlet-api:2.4::jar" );
expectedNodes.add( "javax.transaction:jta:1.0.1B::jar" );
expectedNodes.add( "jaxen:jaxen:1.1::jar" );
expectedNodes.add( "jdom:jdom:1.0::jar" );
expectedNodes.add( "jpox:jpox:1.1.7::jar" );
expectedNodes.add( "jtidy:jtidy:4aug2000r7-dev::jar" );
expectedNodes.add( "junit:junit:3.8.1::jar" );
expectedNodes.add( "log4j:log4j:1.2.8::jar" );
expectedNodes.add( "net.java.dev.stax-utils:stax-utils:20060502::jar" );
expectedNodes.add( "net.sf.ehcache:ehcache:1.2.4::jar" );
expectedNodes.add( "ognl:ognl:2.6.7::jar" );
expectedNodes.add( "opensymphony:oscore:2.2.4::jar" );
expectedNodes.add( "opensymphony:sitemesh:2.2.1::jar" );
expectedNodes.add( "opensymphony:webwork:2.2.4::jar" );
expectedNodes.add( "opensymphony:xwork:1.2.1::jar" );
expectedNodes.add( "org.apache.derby:derby:10.1.3.1::jar" );
expectedNodes.add( "org.apache.lucene:lucene-core:2.0.0::jar" );
expectedNodes.add( "org.apache.maven:maven-artifact:2.0.5::jar" );
expectedNodes.add( "org.apache.maven:maven-artifact-manager:2.0.5::jar" );
expectedNodes.add( "org.apache.maven:maven-model:2.0.5::jar" );
expectedNodes.add( "org.apache.maven:maven-profile:2.0.5::jar" );
expectedNodes.add( "org.apache.maven:maven-project:2.0.5::jar" );
expectedNodes.add( "org.apache.maven:maven-repository-metadata:2.0.5::jar" );
expectedNodes.add( "org.apache.maven:maven-settings:2.0.5::jar" );
expectedNodes.add( "org.apache.maven.archiva:archiva-applet:1.0-alpha-2-SNAPSHOT::jar" );
expectedNodes.add( "org.apache.maven.archiva:archiva-artifact-reports:1.0-alpha-2-SNAPSHOT::jar" );
expectedNodes.add( "org.apache.maven.archiva:archiva-common:1.0-alpha-2-SNAPSHOT::jar" );
expectedNodes.add( "org.apache.maven.archiva:archiva-configuration:1.0-alpha-2-SNAPSHOT::jar" );
expectedNodes.add( "org.apache.maven.archiva:archiva-consumer-api:1.0-alpha-2-SNAPSHOT::jar" );
expectedNodes.add( "org.apache.maven.archiva:archiva-core-consumers:1.0-alpha-2-SNAPSHOT::jar" );
expectedNodes.add( "org.apache.maven.archiva:archiva-database:1.0-alpha-2-SNAPSHOT::jar" );
expectedNodes.add( "org.apache.maven.archiva:archiva-database-consumers:1.0-alpha-2-SNAPSHOT::jar" );
expectedNodes.add( "org.apache.maven.archiva:archiva-indexer:1.0-alpha-2-SNAPSHOT::jar" );
expectedNodes.add( "org.apache.maven.archiva:archiva-lucene-consumers:1.0-alpha-2-SNAPSHOT::jar" );
expectedNodes.add( "org.apache.maven.archiva:archiva-model:1.0-alpha-2-SNAPSHOT::jar" );
expectedNodes.add( "org.apache.maven.archiva:archiva-policies:1.0-alpha-2-SNAPSHOT::jar" );
expectedNodes.add( "org.apache.maven.archiva:archiva-proxy:1.0-alpha-2-SNAPSHOT::jar" );
expectedNodes.add( "org.apache.maven.archiva:archiva-report-manager:1.0-alpha-2-SNAPSHOT::jar" );
expectedNodes.add( "org.apache.maven.archiva:archiva-repository-layer:1.0-alpha-2-SNAPSHOT::jar" );
expectedNodes.add( "org.apache.maven.archiva:archiva-scheduled:1.0-alpha-2-SNAPSHOT::jar" );
expectedNodes.add( "org.apache.maven.archiva:archiva-security:1.0-alpha-2-SNAPSHOT::jar" );
expectedNodes.add( "org.apache.maven.archiva:archiva-signature-consumers:1.0-alpha-2-SNAPSHOT::jar" );
expectedNodes.add( "org.apache.maven.archiva:archiva-xml-tools:1.0-alpha-2-SNAPSHOT::jar" );
expectedNodes.add( "org.apache.maven.shared:maven-app-configuration-model:1.0::jar" );
expectedNodes.add( "org.apache.maven.shared:maven-app-configuration-web:1.0::jar" );
expectedNodes.add( "org.apache.maven.wagon:wagon-file:1.0-beta-2::jar" );
expectedNodes.add( "org.apache.maven.wagon:wagon-http-lightweight:1.0-beta-2::jar" );
expectedNodes.add( "org.apache.maven.wagon:wagon-http-shared:1.0-beta-2::jar" );
expectedNodes.add( "org.apache.maven.wagon:wagon-provider-api:1.0-beta-2::jar" );
expectedNodes.add( "org.codehaus.plexus:plexus-classworlds:1.2-alpha-7::jar" );
expectedNodes.add( "org.codehaus.plexus:plexus-component-api:1.0-alpha-22::jar" );
expectedNodes.add( "org.codehaus.plexus:plexus-container-default:1.0-alpha-22::jar" );
expectedNodes.add( "org.codehaus.plexus:plexus-digest:1.1::jar" );
expectedNodes.add( "org.codehaus.plexus:plexus-ehcache:1.0-alpha-2::jar" );
expectedNodes.add( "org.codehaus.plexus:plexus-expression-evaluator:1.0-alpha-1::jar" );
expectedNodes.add( "org.codehaus.plexus:plexus-jdo2:1.0-alpha-8::jar" );
expectedNodes.add( "org.codehaus.plexus:plexus-mail-sender-api:1.0-alpha-6::jar" );
expectedNodes.add( "org.codehaus.plexus:plexus-mail-sender-javamail:1.0-alpha-6::jar" );
expectedNodes.add( "org.codehaus.plexus:plexus-quartz:1.0-alpha-3::jar" );
expectedNodes.add( "org.codehaus.plexus:plexus-slf4j-logging:1.1-alpha-1::jar" );
expectedNodes.add( "org.codehaus.plexus:plexus-taskqueue:1.0-alpha-6::jar" );
expectedNodes.add( "org.codehaus.plexus:plexus-utils:1.4::jar" );
expectedNodes.add( "org.codehaus.plexus:plexus-velocity:1.1.2::jar" );
expectedNodes.add( "org.codehaus.plexus:plexus-xwork-integration:1.0-alpha-6::jar" );
expectedNodes.add( "org.codehaus.plexus.cache:plexus-cache-api:1.0-alpha-2::jar" );
expectedNodes.add( "org.codehaus.plexus.cache:plexus-cache-ehcache:1.0-alpha-2::jar" );
expectedNodes.add( "org.codehaus.plexus.redback:redback-authentication-api:1.0-alpha-1::jar" );
expectedNodes.add( "org.codehaus.plexus.redback:redback-authentication-keys:1.0-alpha-1::jar" );
expectedNodes.add( "org.codehaus.plexus.redback:redback-authentication-users:1.0-alpha-1::jar" );
expectedNodes.add( "org.codehaus.plexus.redback:redback-authorization-api:1.0-alpha-1::jar" );
expectedNodes.add( "org.codehaus.plexus.redback:redback-authorization-rbac:1.0-alpha-1::jar" );
expectedNodes.add( "org.codehaus.plexus.redback:redback-common-jdo:1.0-alpha-1::jar" );
expectedNodes.add( "org.codehaus.plexus.redback:redback-configuration:1.0-alpha-1::jar" );
expectedNodes.add( "org.codehaus.plexus.redback:redback-keys-api:1.0-alpha-1::jar" );
expectedNodes.add( "org.codehaus.plexus.redback:redback-keys-cached:1.0-alpha-1::jar" );
expectedNodes.add( "org.codehaus.plexus.redback:redback-keys-jdo:1.0-alpha-1::jar" );
expectedNodes.add( "org.codehaus.plexus.redback:redback-policy:1.0-alpha-1::jar" );
expectedNodes.add( "org.codehaus.plexus.redback:redback-rbac-cached:1.0-alpha-1::jar" );
expectedNodes.add( "org.codehaus.plexus.redback:redback-rbac-jdo:1.0-alpha-1::jar" );
expectedNodes.add( "org.codehaus.plexus.redback:redback-rbac-model:1.0-alpha-1::jar" );
expectedNodes.add( "org.codehaus.plexus.redback:redback-rbac-role-manager:1.0-alpha-1::jar" );
expectedNodes.add( "org.codehaus.plexus.redback:redback-system:1.0-alpha-1::jar" );
expectedNodes.add( "org.codehaus.plexus.redback:redback-taglib:1.0-alpha-1::jar" );
expectedNodes.add( "org.codehaus.plexus.redback:redback-users-api:1.0-alpha-1::jar" );
expectedNodes.add( "org.codehaus.plexus.redback:redback-users-cached:1.0-alpha-1::jar" );
expectedNodes.add( "org.codehaus.plexus.redback:redback-users-jdo:1.0-alpha-1::jar" );
expectedNodes.add( "org.codehaus.plexus.redback:redback-xwork-content:1.0-alpha-1::war" );
expectedNodes.add( "org.codehaus.plexus.redback:redback-xwork-integration:1.0-alpha-1::jar" );
expectedNodes.add( "org.codehaus.plexus.registry:plexus-registry-api:1.0-alpha-2::jar" );
expectedNodes.add( "org.codehaus.plexus.registry:plexus-registry-commons:1.0-alpha-2::jar" );
expectedNodes.add( "org.codehaus.plexus.webdav:plexus-webdav-api:1.0-alpha-2::jar" );
expectedNodes.add( "org.codehaus.plexus.webdav:plexus-webdav-simple:1.0-alpha-2::jar" );
expectedNodes.add( "org.codehaus.woodstox:wstx-asl:3.2.1::jar" );
expectedNodes.add( "org.extremecomponents:extremecomponents:1.0.1::jar" );
expectedNodes.add( "org.rifers:rife-continuations:0.0.2::jar" );
expectedNodes.add( "org.slf4j:slf4j-api:1.2::jar" );
expectedNodes.add( "org.slf4j:slf4j-log4j12:1.2::jar" );
expectedNodes.add( "org.slf4j:slf4j-simple:1.2::jar" );
expectedNodes.add( "quartz:quartz:1.4.5::jar" );
expectedNodes.add( "stax:stax-api:1.0.1::jar" );
expectedNodes.add( "taglibs:standard:1.1.2::jar" );
expectedNodes.add( "velocity:velocity:1.4::jar" );
expectedNodes.add( "velocity:velocity-dep:1.4::jar" );
expectedNodes.add( "xerces:xercesImpl:2.6.2::jar" );
expectedNodes.add( "xml-apis:xml-apis:1.3.03::jar" );

assertGraph( graph, expectedRootRef, expectedNodes );
}

}

+ 0
- 3469
archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/ArchivaWebappMemoryRepository.java
File diff suppressed because it is too large
View File


+ 0
- 86
archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/ArchivaXmlToolsDependencyGraphTest.java View File

@@ -1,86 +0,0 @@
package org.apache.maven.archiva.dependency.graph;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.maven.archiva.dependency.DependencyGraphFactory;
import org.apache.maven.archiva.model.DependencyScope;
import org.apache.maven.archiva.model.VersionedReference;

import java.util.ArrayList;
import java.util.List;

/**
* ArchivaXmlToolsDependencyGraphTest
*
* DependencyGraphTest for testing <code>org.apache.maven.archiva:archiva-xml-tools:1.0-alpha-2-SNAPSHOT</code>
*
* Generated by <code>archivadev:generate-dependency-tests</code> plugin
* @version $Id$
*/
public class ArchivaXmlToolsDependencyGraphTest
extends AbstractDependencyGraphFactoryTestCase
{
public void testResolvedDepsToNodes()
throws GraphTaskException
{
MemoryRepositoryDependencyGraphBuilder graphBuilder =
new MemoryRepositoryDependencyGraphBuilder();
MemoryRepository repository = new ArchivaXmlToolsMemoryRepository();
graphBuilder.setMemoryRepository( repository );

// Create the factory, and add the test resolver.
DependencyGraphFactory factory = new DependencyGraphFactory();
factory.setGraphBuilder( graphBuilder );
factory.setDesiredScope( DependencyScope.TEST );

// Get the model to resolve from
VersionedReference rootRef = toVersionedReference( "org.apache.maven.archiva:archiva-xml-tools:1.0-alpha-2-SNAPSHOT");

// Perform the resolution.
DependencyGraph graph = factory.getGraph( rootRef );

// Test the results.
assertNotNull( "Graph shouldn't be null.", graph );

String expectedRootRef = "org.apache.maven.archiva:archiva-xml-tools:1.0-alpha-2-SNAPSHOT";
List<String> expectedNodes = new ArrayList<String>();

// Check for all nodes, regardless of scope.
expectedNodes.clear();
expectedNodes.add( "commons-collections:commons-collections:3.2::jar" );
expectedNodes.add( "commons-lang:commons-lang:2.2::jar" );
expectedNodes.add( "dom4j:dom4j:1.6.1::jar" );
expectedNodes.add( "jaxen:jaxen:1.1::jar" );
expectedNodes.add( "junit:junit:3.8.1::jar" );
expectedNodes.add( "log4j:log4j:1.2.8::jar" );
expectedNodes.add( "org.apache.maven.archiva:archiva-common:1.0-alpha-2-SNAPSHOT::jar" );
expectedNodes.add( "org.codehaus.plexus:plexus-classworlds:1.2-alpha-7::jar" );
expectedNodes.add( "org.codehaus.plexus:plexus-component-api:1.0-alpha-22::jar" );
expectedNodes.add( "org.codehaus.plexus:plexus-container-default:1.0-alpha-22::jar" );
expectedNodes.add( "org.codehaus.plexus:plexus-utils:1.4::jar" );
expectedNodes.add( "org.slf4j:slf4j-api:1.2::jar" );
expectedNodes.add( "org.slf4j:slf4j-log4j12:1.2::jar" );
expectedNodes.add( "xerces:xercesImpl:2.6.2::jar" );
expectedNodes.add( "xml-apis:xml-apis:1.0.b2::jar" );

assertGraph( graph, expectedRootRef, expectedNodes );
}

}

+ 0
- 3469
archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/ArchivaXmlToolsMemoryRepository.java
File diff suppressed because it is too large
View File


+ 0
- 98
archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/ContinuumStoreDependencyGraphTest.java View File

@@ -1,98 +0,0 @@
package org.apache.maven.archiva.dependency.graph;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.maven.archiva.dependency.DependencyGraphFactory;
import org.apache.maven.archiva.model.DependencyScope;
import org.apache.maven.archiva.model.VersionedReference;

import java.util.ArrayList;
import java.util.List;

/**
* ContinuumStoreDependencyGraphTest
*
* DependencyGraphTest for testing <code>org.apache.maven.continuum:continuum-store:1.1-SNAPSHOT</code>
*
* Generated by <code>archivadev:generate-dependency-tests</code> plugin
* @version $Id$
*/
public class ContinuumStoreDependencyGraphTest
extends AbstractDependencyGraphFactoryTestCase
{
public void testResolvedDepsToNodes()
throws GraphTaskException
{
MemoryRepositoryDependencyGraphBuilder graphBuilder =
new MemoryRepositoryDependencyGraphBuilder();
MemoryRepository repository = new ContinuumStoreMemoryRepository();
graphBuilder.setMemoryRepository( repository );

// Create the factory, and add the test resolver.
DependencyGraphFactory factory = new DependencyGraphFactory();
factory.setGraphBuilder( graphBuilder );
factory.setDesiredScope( DependencyScope.TEST );

// Get the model to resolve from
VersionedReference rootRef = toVersionedReference( "org.apache.maven.continuum:continuum-store:1.1-SNAPSHOT");

// Perform the resolution.
DependencyGraph graph = factory.getGraph( rootRef );

// Test the results.
assertNotNull( "Graph shouldn't be null.", graph );

String expectedRootRef = "org.apache.maven.continuum:continuum-store:1.1-SNAPSHOT";
List<String> expectedNodes = new ArrayList<String>();

// Check for all nodes, regardless of scope.
expectedNodes.clear();
expectedNodes.add( "ant:ant:1.6::jar" );
expectedNodes.add( "geronimo-spec:geronimo-spec-jta:1.0.1B-rc2::jar" );
expectedNodes.add( "hsqldb:hsqldb:1.7.3.3::jar" );
expectedNodes.add( "jakarta-regexp:jakarta-regexp:1.4::jar" );
expectedNodes.add( "javax.jdo:jdo2-api:2.0::jar" );
expectedNodes.add( "javax.resource:connector:1.0::jar" );
expectedNodes.add( "javax.transaction:jta:1.0.1B::jar" );
expectedNodes.add( "jmock:jmock:1.0.1::jar" );
expectedNodes.add( "jpox:jpox:1.1.7::jar" );
expectedNodes.add( "jpox:jpox-enhancer:1.1.7::jar" );
expectedNodes.add( "junit:junit:3.8.1::jar" );
expectedNodes.add( "log4j:log4j:1.2.8::jar" );
expectedNodes.add( "net.java.dev.stax-utils:stax-utils:20060502::jar" );
expectedNodes.add( "ognl:ognl:2.6.7::jar" );
expectedNodes.add( "org.apache.bcel:bcel:5.2::jar" );
expectedNodes.add( "org.apache.maven.continuum:continuum-api:1.1-SNAPSHOT::jar" );
expectedNodes.add( "org.apache.maven.continuum:continuum-model:1.1-SNAPSHOT::jar" );
expectedNodes.add( "org.apache.maven.continuum:continuum-test:1.1-SNAPSHOT::jar" );
expectedNodes.add( "org.codehaus.plexus:plexus-classworlds:1.2-alpha-7::jar" );
expectedNodes.add( "org.codehaus.plexus:plexus-component-api:1.0-alpha-20::jar" );
expectedNodes.add( "org.codehaus.plexus:plexus-container-default:1.0-alpha-20::jar" );
expectedNodes.add( "org.codehaus.plexus:plexus-formica:1.0-beta-13::jar" );
expectedNodes.add( "org.codehaus.plexus:plexus-i18n:1.0-beta-6::jar" );
expectedNodes.add( "org.codehaus.plexus:plexus-jdo2:1.0-alpha-8::jar" );
expectedNodes.add( "org.codehaus.plexus:plexus-utils:1.4::jar" );
expectedNodes.add( "oro:oro:2.0.6::jar" );
expectedNodes.add( "stax:stax-api:1.0.1::jar" );

assertGraph( graph, expectedRootRef, expectedNodes );
}

}

+ 0
- 4142
archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/ContinuumStoreMemoryRepository.java
File diff suppressed because it is too large
View File


+ 0
- 74
archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/DepManDeepVersionDependencyGraphTest.java View File

@@ -1,74 +0,0 @@
package org.apache.maven.archiva.dependency.graph;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.maven.archiva.dependency.DependencyGraphFactory;
import org.apache.maven.archiva.model.DependencyScope;
import org.apache.maven.archiva.model.VersionedReference;

import java.util.ArrayList;
import java.util.List;

/**
* DepManDeepVersionDependencyGraphTest
*
* DependencyGraphTest for testing <code>net.example.depman.deepversion:A:1.0</code>
*
* @version $Id$
*/
public class DepManDeepVersionDependencyGraphTest
extends AbstractDependencyGraphFactoryTestCase
{
public void testResolvedDepsToNodes()
throws GraphTaskException
{
MemoryRepositoryDependencyGraphBuilder graphBuilder = new MemoryRepositoryDependencyGraphBuilder();
MemoryRepository repository = new DepManDeepVersionMemoryRepository();
graphBuilder.setMemoryRepository( repository );

// Create the factory, and add the test resolver.
DependencyGraphFactory factory = new DependencyGraphFactory();
factory.setGraphBuilder( graphBuilder );
factory.setDesiredScope( DependencyScope.TEST );

// Get the model to resolve from
VersionedReference rootRef = toVersionedReference( "net.example.depman.deepversion:A:1.0" );

// Perform the resolution.
DependencyGraph graph = factory.getGraph( rootRef );

// Test the results.
assertNotNull( "Graph shouldn't be null.", graph );

String expectedRootRef = "net.example.depman.deepversion:A:1.0";
List<String> expectedNodes = new ArrayList<String>();

// Check for all nodes, regardless of scope.
expectedNodes.clear();
expectedNodes.add( "net.example.depman.deepversion:B:1.0::jar" );
expectedNodes.add( "net.example.depman.deepversion:C:1.0::jar" );
expectedNodes.add( "net.example.depman.deepversion:D:2.0::jar" );
expectedNodes.add( "net.example.depman.deepversion:E:3.0::jar" );
expectedNodes.add( "net.example.depman.deepversion:F:1.0::jar" );

assertGraph( graph, expectedRootRef, expectedNodes );
}

}

+ 0
- 77
archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/DepManDeepVersionMemoryRepository.java View File

@@ -1,77 +0,0 @@
package org.apache.maven.archiva.dependency.graph;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.maven.archiva.model.ArchivaProjectModel;

/**
* DepManDeepVersionMemoryRepository
*
* MemoryRepository for testing <code>net.example.depman.deepversion:A:1.0</code>
*
* @version $Id$
*/
public class DepManDeepVersionMemoryRepository
extends AbstractMemoryRepository
{
public void initialize()
{
ArchivaProjectModel model;

model = toModel( "net.example.depman.deepversion:A:1.0" );
model.addDependency( toDependency( "net.example.depman.deepversion:B:1.0::jar" ) );
model.addDependency( toDependency( "net.example.depman.deepversion:C:1.0::jar" ) );
model.addDependencyManagement( toDependency( "net.example.depman.deepversion:D:2.0::jar" ) );
addModel( model );
/* Having a depman in A for D:2.0 will cause an orphaned E:2.0 during the depman
* application phase.
*
* This is intentional, to test out the depman application and recovery.
*/

model = toModel( "net.example.depman.deepversion:B:1.0" );
model.addDependency( toDependency( "net.example.depman.deepversion:D:1.0::jar" ) );
addModel( model );

model = toModel( "net.example.depman.deepversion:E:2.0" );
addModel( model );
model = toModel( "net.example.depman.deepversion:E:3.0" );
model.addDependency( toDependency( "net.example.depman.deepversion:F:1.0::jar" ) );
addModel( model );
model = toModel( "net.example.depman.deepversion:F:1.0" );
addModel( model );

model = toModel( "net.example.depman.deepversion:C:1.0" );
model.addDependency( toDependency( "net.example.depman.deepversion:D:1.0::jar" ) );
addModel( model );

model = toModel( "net.example.depman.deepversion:D:1.0" );
model.addDependency( toDependency( "net.example.depman.deepversion:E:2.0::jar" ) );
addModel( model );

model = toModel( "net.example.depman.deepversion:D:2.0" );
model.addDependency( toDependency( "net.example.depman.deepversion:E:3.0::jar" ) );
addModel( model );

}
}

+ 0
- 336
archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/GraphvizDotTool.java View File

@@ -1,336 +0,0 @@
package org.apache.maven.archiva.dependency.graph;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

import junit.framework.Assert;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.archiva.dependency.DependencyGraphFactory;
import org.apache.maven.archiva.model.DependencyScope;
import org.apache.maven.archiva.model.VersionedReference;

/**
* GraphvizDotTool - testing utility to help understand the graph.
*
* @version $Id$
*/
public class GraphvizDotTool
implements GraphListener
{
private int phaseNumber = 0;

protected VersionedReference toVersionedReference( String key )
{
String parts[] = StringUtils.splitPreserveAllTokens( key, ':' );
Assert.assertEquals( "Versioned Reference [" + key + "] part count.", 3, parts.length );

VersionedReference ref = new VersionedReference();
ref.setGroupId( parts[0] );
ref.setArtifactId( parts[1] );
ref.setVersion( parts[2] );
return ref;
}

private DependencyGraph getDependencyGraph( MemoryRepository repository, String rootRefKey )
throws GraphTaskException
{
MemoryRepositoryDependencyGraphBuilder graphBuilder = new MemoryRepositoryDependencyGraphBuilder();
graphBuilder.setMemoryRepository( repository );

// Create the factory, and add the test resolver.
DependencyGraphFactory factory = new DependencyGraphFactory();
factory.setGraphBuilder( graphBuilder );
factory.setDesiredScope( DependencyScope.TEST );
factory.addGraphListener( this );

// Get the model to resolve from
VersionedReference rootRef = toVersionedReference( rootRefKey );

// Perform the resolution.
phaseNumber = 0;
DependencyGraph graph = factory.getGraph( rootRef );

// Test the results.
Assert.assertNotNull( "Graph shouldn't be null.", graph );

return graph;
}

public void testGenerateDots()
throws GraphTaskException
{
getDependencyGraph( new ArchivaWebappMemoryRepository(),
"org.apache.maven.archiva:archiva-webapp:1.0-alpha-2-SNAPSHOT" );

// getDependencyGraph( new ArchivaCommonMemoryRepository(),
// "org.apache.maven.archiva:archiva-common:1.0-alpha-2-SNAPSHOT" );
//
// getDependencyGraph( new ArchivaXmlToolsMemoryRepository(),
// "org.apache.maven.archiva:archiva-xml-tools:1.0-alpha-2-SNAPSHOT" );
//
// getDependencyGraph( new ContinuumStoreMemoryRepository(),
// "org.apache.maven.continuum:continuum-store:1.1-SNAPSHOT" );
//
// getDependencyGraph( new MavenProjectInfoReportsPluginMemoryRepository(),
// "org.apache.maven.plugins:maven-project-info-reports-plugin:2.1-SNAPSHOT" );
//
// getDependencyGraph( new WagonManagerMemoryRepository(), "org.apache.maven.wagon:wagon-manager:2.0-SNAPSHOT" );

getDependencyGraph( new DepManDeepVersionMemoryRepository(), "net.example.depman.deepversion:A:1.0" );
}

public void dependencyResolutionEvent( DependencyResolutionEvent event )
{
/* do nothing */
}

public void graphError( GraphTaskException e, DependencyGraph currentGraph )
{
/* do nothing */
}

public void graphPhaseEvent( GraphPhaseEvent event )
{
String graphId = event.getGraph().getRootNode().getArtifact().getArtifactId();
String title = "Graph: " + graphId;

switch ( event.getType() )
{
case GraphPhaseEvent.GRAPH_TASK_POST:
phaseNumber++;
title += " - Phase: " + phaseNumber + " - Task: " + event.getTask().getTaskId();
writeDot( "target/graph_" + graphId + "_" + phaseNumber + "_" + event.getTask().getTaskId() + ".dot",
event.getGraph(), title );
break;
case GraphPhaseEvent.GRAPH_DONE:
title += " FINISHED";
writeDot( "target/graph_" + graphId + ".dot", event.getGraph(), title );
break;
}
}

private void writeDot( String outputFilename, DependencyGraph graph, String title )
{
System.out.println( "Writing Graphviz output: " + outputFilename );
try
{
File outputFile = new File( outputFilename );
FileWriter writer = new FileWriter( outputFile );
PrintWriter dot = new PrintWriter( writer );

dot.println( "// Auto generated dot file from plexus-graph-visualizer-graphviz." );

dot.println( "digraph example {" );

dot.println( "" );

dot.println( " // Graph Defaults" );
dot.println( " graph [" );
dot.println( " bgcolor=\"#ffffff\"," );
dot.println( " fontname=\"Helvetica\"," );
dot.println( " fontsize=\"11\"," );
dot.println( " label=\"" + title + "\"," );
dot.println( " labeljust=\"l\"" );
dot.println( " rankdir=\"LR\"" );
dot.println( " ];" );

// Node Defaults.

dot.println( "" );
dot.println( " // Node Defaults." );
dot.println( " node [" );
dot.println( " fontname=\"Helvetica\"," );
dot.println( " fontsize=\"11\"," );
dot.println( " shape=\"box\"" );
dot.println( " ];" );

// Edge Defaults.

dot.println( "" );
dot.println( " // Edge Defaults." );
dot.println( " edge [" );
dot.println( " arrowsize=\"0.8\"" );
dot.println( " fontsize=\"11\"," );
dot.println( " ];" );

for ( DependencyGraphNode node : graph.getNodes() )
{
writeNode( dot, graph, node );
}

for ( DependencyGraphEdge edge : graph.getEdges() )
{
DependencyGraphNode from = graph.getNode( edge.getNodeFrom() );
DependencyGraphNode to = graph.getNode( edge.getNodeTo() );

writeEdge( dot, edge, from, to );
}

dot.println( "}" );
dot.flush();
dot.close();
}
catch ( IOException e )
{
System.err.println( "Unable to write GraphViz file " + outputFilename + " : " + e.getMessage() );
e.printStackTrace( System.err );
}
}

private String toLabel( DependencyGraphNode node )
{
StringBuffer lbl = new StringBuffer();

lbl.append( node.getArtifact().getGroupId() ).append( "\n" );
lbl.append( node.getArtifact().getArtifactId() ).append( "\n" );
lbl.append( node.getArtifact().getVersion() );

return StringEscapeUtils.escapeJava( lbl.toString() );
}

private String toId( DependencyGraphNode node )
{
StringBuffer id = new StringBuffer();

String raw = DependencyGraphKeys.toKey( node.getArtifact() );

for ( int i = 0; i < raw.length(); i++ )
{
char c = raw.charAt( i );
if ( Character.isLetterOrDigit( c ) )
{
id.append( Character.toUpperCase( c ) );
}
else if ( ( c == '-' ) || ( c == '_' ) )
{
id.append( "_" );
}
}

return id.toString();
}

private void writeNode( PrintWriter dot, DependencyGraph graph, DependencyGraphNode node )
{
dot.println( "" );
dot.println( " // Node" );
dot.println( " \"" + toId( node ) + "\" [" );
dot.println( " label=\"" + toLabel( node ) + "\"," );

boolean orphan = CollectionUtils.isEmpty( graph.getEdgesTo( node ) );

if ( node.isFromParent() )
{
dot.println( " color=\"#FF0000\"," );
dot.println( " shape=ellipse," );
}
else
{
dot.println( " shape=box," );
}

if ( node.isConflicted() )
{
// dot.println( " fontcolor=\"#FF88FF\"," );
dot.println( " style=filled," );
dot.println( " fillcolor=\"#88FF88\"," );
}
else if ( orphan )
{
dot.println( " style=filled," );
dot.println( " fillcolor=\"#8888FF\"," );
}

dot.println( " ];" );
}

private void writeEdge( PrintWriter dot, DependencyGraphEdge edge, DependencyGraphNode from, DependencyGraphNode to )
{
dot.println( "" );
dot.println( " // Edge" );

dot.println( " \"" + toId( from ) + "\" -> \"" + toId( to ) + "\" [" );

if ( edge.isDisabled() )
{
switch ( edge.getDisabledType() )
{
case DependencyGraph.DISABLED_CYCLIC:
dot.println( " color=\"#FF0000\"," );
break;
case DependencyGraph.DISABLED_OPTIONAL:
dot.println( " color=\"#FF00FF\"," );
break;
case DependencyGraph.DISABLED_NEARER_DEP:
dot.println( " color=\"#00FF00\"," );
break;
case DependencyGraph.DISABLED_NEARER_EDGE:
dot.println( " color=\"#88FF88\"," );
break;
default:
case DependencyGraph.DISABLED_EXCLUDED:
dot.println( " color=\"#0000FF\"," );
break;
}

dot.println( " label=\"" + edge.getDisabledReason() + "\"," );
dot.println( " fontsize=\"8\"," );
}
else if ( DependencyScope.TEST.equals( edge.getScope() ) )
{
dot.println( " style=\"dashed\"," );
dot.println( " color=\"#DDDDDD\"," );
}
else if ( DependencyScope.RUNTIME.equals( edge.getScope() ) )
{
dot.println( " style=\"dashed\"," );
dot.println( " color=\"#DDFFDD\"," );
dot.println( " label=\"runtime\"," );
dot.println( " fontsize=\"8\"," );
}
else if ( DependencyScope.PROVIDED.equals( edge.getScope() ) )
{
dot.println( " style=\"dashed\"," );
dot.println( " color=\"#DDDDFF\"," );
dot.println( " label=\"provided\"," );
dot.println( " fontsize=\"8\"," );
}
else if ( DependencyScope.SYSTEM.equals( edge.getScope() ) )
{
dot.println( " style=\"dashed\"," );
dot.println( " color=\"#FFDDDD\"," );
dot.println( " label=\"system\"," );
dot.println( " fontsize=\"8\"," );
}

dot.println( " arrowtail=none," );
dot.println( " arrowhead=normal" );

dot.println( " ];" );
}

}

+ 0
- 135
archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/MavenProjectInfoReportsPluginDependencyGraphTest.java View File

@@ -1,135 +0,0 @@
package org.apache.maven.archiva.dependency.graph;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/


/**
* MavenProjectInfoReportsPluginDependencyGraphTest
*
* DependencyGraphTest for testing <code>org.apache.maven.plugins:maven-project-info-reports-plugin:2.1-SNAPSHOT</code>
*
* Generated by <code>archivadev:generate-dependency-tests</code> plugin
* @version $Id$
*/
public class MavenProjectInfoReportsPluginDependencyGraphTest
extends AbstractDependencyGraphFactoryTestCase
{
public void testResolvedDepsToNodes()
throws GraphTaskException
{
/* TODO: Can't test a snapshot dependency from the repository
MemoryRepositoryDependencyGraphBuilder graphBuilder =
new MemoryRepositoryDependencyGraphBuilder();
MemoryRepository repository = new MavenProjectInfoReportsPluginMemoryRepository();
graphBuilder.setMemoryRepository( repository );

// Create the factory, and add the test resolver.
DependencyGraphFactory factory = new DependencyGraphFactory();
factory.setGraphBuilder( graphBuilder );
factory.setDesiredScope( DependencyScope.TEST );

// Get the model to resolve from
VersionedReference rootRef = toVersionedReference( "org.apache.maven.plugins:maven-project-info-reports-plugin:2.1-SNAPSHOT");

// Perform the resolution.
DependencyGraph graph = factory.getGraph( rootRef );

// Test the results.
assertNotNull( "Graph shouldn't be null.", graph );

String expectedRootRef = "org.apache.maven.plugins:maven-project-info-reports-plugin:2.1-SNAPSHOT";
List expectedNodes = new ArrayList();

// Check for all nodes, regardless of scope.
expectedNodes.clear();
expectedNodes.add( "classworlds:classworlds:1.1-alpha-2::jar" );
expectedNodes.add( "com.jcraft:jsch:0.1.27::jar" );
expectedNodes.add( "commons-beanutils:commons-beanutils:1.7.0::jar" );
expectedNodes.add( "commons-cli:commons-cli:1.0::jar" );
expectedNodes.add( "commons-collections:commons-collections:3.1::jar" );
expectedNodes.add( "commons-digester:commons-digester:1.6::jar" );
expectedNodes.add( "commons-logging:commons-logging:1.0.4::jar" );
expectedNodes.add( "commons-validator:commons-validator:1.2.0::jar" );
expectedNodes.add( "httpunit:httpunit:1.6::jar" );
expectedNodes.add( "jakarta-regexp:jakarta-regexp:1.4::jar" );
expectedNodes.add( "javax.servlet:servlet-api:2.3::jar" );
expectedNodes.add( "jtidy:jtidy:4aug2000r7-dev::jar" );
expectedNodes.add( "junit:junit:3.8.1::jar" );
expectedNodes.add( "nekohtml:nekohtml:0.9.1::jar" );
expectedNodes.add( "org.apache.bcel:bcel:5.2::jar" );
expectedNodes.add( "org.apache.maven:maven-artifact:2.0.4::jar" );
expectedNodes.add( "org.apache.maven:maven-artifact-manager:2.0.2::jar" );
expectedNodes.add( "org.apache.maven:maven-core:2.0::jar" );
expectedNodes.add( "org.apache.maven:maven-error-diagnostics:2.0::jar" );
expectedNodes.add( "org.apache.maven:maven-model:2.0.4::jar" );
expectedNodes.add( "org.apache.maven:maven-monitor:2.0::jar" );
expectedNodes.add( "org.apache.maven:maven-plugin-api:2.0.4::jar" );
expectedNodes.add( "org.apache.maven:maven-plugin-descriptor:2.0::jar" );
expectedNodes.add( "org.apache.maven:maven-plugin-parameter-documenter:2.0::jar" );
expectedNodes.add( "org.apache.maven:maven-plugin-registry:2.0::jar" );
expectedNodes.add( "org.apache.maven:maven-profile:2.0::jar" );
expectedNodes.add( "org.apache.maven:maven-project:2.0.4::jar" );
expectedNodes.add( "org.apache.maven:maven-repository-metadata:2.0::jar" );
expectedNodes.add( "org.apache.maven:maven-settings:2.0.4::jar" );
expectedNodes.add( "org.apache.maven.doxia:doxia-core:1.0-alpha-8::jar" );
expectedNodes.add( "org.apache.maven.doxia:doxia-decoration-model:1.0-alpha-8::jar" );
expectedNodes.add( "org.apache.maven.doxia:doxia-sink-api:1.0-alpha-8::jar" );
expectedNodes.add( "org.apache.maven.doxia:doxia-site-renderer:1.0-alpha-8::jar" );
expectedNodes.add( "org.apache.maven.reporting:maven-reporting-api:2.0.4::jar" );
expectedNodes.add( "org.apache.maven.reporting:maven-reporting-impl:2.0.4::jar" );
expectedNodes.add( "org.apache.maven.scm:maven-scm-api:1.0-beta-4::jar" );
expectedNodes.add( "org.apache.maven.scm:maven-scm-manager-plexus:1.0-beta-4::jar" );
expectedNodes.add( "org.apache.maven.scm:maven-scm-provider-clearcase:1.0-beta-4::jar" );
expectedNodes.add( "org.apache.maven.scm:maven-scm-provider-cvs-commons:1.0-beta-4::jar" );
expectedNodes.add( "org.apache.maven.scm:maven-scm-provider-cvsexe:1.0-beta-4::jar" );
expectedNodes.add( "org.apache.maven.scm:maven-scm-provider-perforce:1.0-beta-4::jar" );
expectedNodes.add( "org.apache.maven.scm:maven-scm-provider-starteam:1.0-beta-4::jar" );
expectedNodes.add( "org.apache.maven.scm:maven-scm-provider-svn-commons:1.0-beta-4::jar" );
expectedNodes.add( "org.apache.maven.scm:maven-scm-provider-svnexe:1.0-beta-4::jar" );
expectedNodes.add( "org.apache.maven.shared:maven-dependency-tree:1.0-alpha-2::jar" );
expectedNodes.add( "org.apache.maven.shared:maven-plugin-testing-harness:1.0::jar" );
expectedNodes.add( "org.apache.maven.shared:maven-shared-jar:1.0-SNAPSHOT::jar" );
expectedNodes.add( "org.apache.maven.wagon:wagon-file:1.0-beta-2::jar" );
expectedNodes.add( "org.apache.maven.wagon:wagon-http-lightweight:1.0-beta-2::jar" );
expectedNodes.add( "org.apache.maven.wagon:wagon-http-shared:1.0-beta-2::jar" );
expectedNodes.add( "org.apache.maven.wagon:wagon-provider-api:1.0-beta-2::jar" );
expectedNodes.add( "org.apache.maven.wagon:wagon-ssh:1.0-beta-2::jar" );
expectedNodes.add( "org.apache.maven.wagon:wagon-ssh-common:1.0-beta-2::jar" );
expectedNodes.add( "org.codehaus.plexus:plexus-container-default:1.0-alpha-9::jar" );
expectedNodes.add( "org.codehaus.plexus:plexus-digest:1.0::jar" );
expectedNodes.add( "org.codehaus.plexus:plexus-i18n:1.0-beta-6::jar" );
expectedNodes.add( "org.codehaus.plexus:plexus-interactivity-api:1.0-alpha-4::jar" );
expectedNodes.add( "org.codehaus.plexus:plexus-utils:1.1::jar" );
expectedNodes.add( "org.codehaus.plexus:plexus-velocity:1.1.3::jar" );
expectedNodes.add( "oro:oro:2.0.7::jar" );
expectedNodes.add( "plexus:plexus-utils:1.0.2::jar" );
expectedNodes.add( "regexp:regexp:1.3::jar" );
expectedNodes.add( "rhino:js:1.5R4.1::jar" );
expectedNodes.add( "velocity:velocity:1.4::jar" );
expectedNodes.add( "velocity:velocity-dep:1.4::jar" );
expectedNodes.add( "xerces:xercesImpl:2.6.2::jar" );
expectedNodes.add( "xerces:xmlParserAPIs:2.2.1::jar" );
expectedNodes.add( "xml-apis:xml-apis:1.0.b2::jar" );

assertGraph( graph, expectedRootRef, expectedNodes );
*/
}

}

+ 0
- 1040
archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/MavenProjectInfoReportsPluginMemoryRepository.java
File diff suppressed because it is too large
View File


+ 0
- 34
archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/MemoryRepository.java View File

@@ -1,34 +0,0 @@
package org.apache.maven.archiva.dependency.graph;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.maven.archiva.model.ArchivaProjectModel;

/**
* MemoryRepository
*
* @version $Id$
*/
public interface MemoryRepository
{
public abstract void addModel( ArchivaProjectModel model );

public abstract ArchivaProjectModel getProjectModel( String groupId, String artifactId, String version );
}

+ 0
- 95
archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/MemoryRepositoryDependencyGraphBuilder.java View File

@@ -1,95 +0,0 @@
package org.apache.maven.archiva.dependency.graph;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.maven.archiva.model.ArchivaProjectModel;
import org.apache.maven.archiva.model.ArtifactReference;
import org.apache.maven.archiva.model.VersionedReference;

/**
* MemoryRepositoryProjectResolver
*
* @version $Id$
*/
public class MemoryRepositoryDependencyGraphBuilder
implements DependencyGraphBuilder
{
private MemoryRepository memoryRepository;

public ArchivaProjectModel resolveProjectModel( VersionedReference reference )
{
ArtifactReference artifact = new ArtifactReference();
artifact.setGroupId( reference.getGroupId() );
artifact.setArtifactId( reference.getArtifactId() );
artifact.setVersion( reference.getVersion() );
artifact.setType( "pom" );

return resolveProjectModel( artifact );
}

public ArchivaProjectModel resolveProjectModel( ArtifactReference reference )
{
ArchivaProjectModel model = memoryRepository
.getProjectModel( reference.getGroupId(), reference.getArtifactId(), reference.getVersion() );

if ( model == null )
{
throw new NullPointerException( "Unable to find model for " + DependencyGraphKeys.toKey( reference ) );
}

if ( model.getParentProject() != null )
{
ArchivaProjectModel parentModel = resolveProjectModel( model.getParentProject() );

model.getDependencies().addAll( parentModel.getDependencies() );
model.getDependencyManagement().addAll( parentModel.getDependencyManagement() );
}

return model;
}

public MemoryRepository getMemoryRepository()
{
return memoryRepository;
}

public void setMemoryRepository( MemoryRepository memoryRepository )
{
this.memoryRepository = memoryRepository;
}

public DependencyGraph createGraph( VersionedReference versionedProjectReference )
{
String groupId = versionedProjectReference.getGroupId();
String artifactId = versionedProjectReference.getArtifactId();
String version = versionedProjectReference.getVersion();

DependencyGraph graph = new DependencyGraph( groupId, artifactId, version );
return graph;
}

public void resolveNode( DependencyGraph graph, DependencyGraphNode fromNode,
VersionedReference versionedProjectReference )
{
ArchivaProjectModel model = resolveProjectModel( fromNode.getArtifact() );

DependencyGraphUtils.addNodeFromModel( model, graph, fromNode );
}
}

+ 0
- 70
archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/SimpleDependencyGraphTest.java View File

@@ -1,70 +0,0 @@
package org.apache.maven.archiva.dependency.graph;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import java.util.ArrayList;
import java.util.List;

import org.apache.maven.archiva.dependency.DependencyGraphFactory;
import org.apache.maven.archiva.model.DependencyScope;
import org.apache.maven.archiva.model.VersionedReference;

/**
* SimpleDependencyGraphTest
*
* @version $Id$
*/
public class SimpleDependencyGraphTest
extends AbstractDependencyGraphFactoryTestCase
{
public void testResolveDependenciesBasic() throws GraphTaskException
{
MemoryRepositoryDependencyGraphBuilder graphBuilder = new MemoryRepositoryDependencyGraphBuilder();
MemoryRepository repository = new SimpleMemoryRepository();
graphBuilder.setMemoryRepository( repository );

// Create the factory, and add the test resolver.
DependencyGraphFactory factory = new DependencyGraphFactory();
factory.setGraphBuilder( graphBuilder );
factory.setDesiredScope( DependencyScope.TEST );

// Get the model to resolve from
VersionedReference rootRef = toVersionedReference( "org.apache.maven.archiva:archiva-commons:1.0" );

// Perform the resolution.
DependencyGraph graph = factory.getGraph( rootRef );

// Test the results.
assertNotNull( "Graph shouldn't be null.", graph );

List<String> expectedNodes = new ArrayList<String>();
expectedNodes.add( "org.apache.maven.archiva:archiva-commons:1.0::pom" );
expectedNodes.add( "org.codehaus.plexus:plexus-digest:1.0::jar" );
expectedNodes.add( "junit:junit:3.8.1::jar" );
assertNodes( graph, expectedNodes );

List<ExpectedEdge> expectedEdges = new ArrayList<ExpectedEdge>();
expectedEdges.add( new ExpectedEdge( "org.apache.maven.archiva:archiva-commons:1.0::pom",
"org.codehaus.plexus:plexus-digest:1.0::jar" ) );
expectedEdges.add( new ExpectedEdge( "org.codehaus.plexus:plexus-digest:1.0::jar", "junit:junit:3.8.1::jar" ) );

assertEdges( graph, expectedEdges );
}
}

+ 0
- 47
archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/SimpleMemoryRepository.java View File

@@ -1,47 +0,0 @@
package org.apache.maven.archiva.dependency.graph;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.maven.archiva.model.ArchivaProjectModel;

/**
* SimpleMemoryRepository
*
* @version $Id$
*/
public class SimpleMemoryRepository
extends AbstractMemoryRepository
{
public void initialize()
{
ArchivaProjectModel model;

model = toModel( "org.codehaus.plexus:plexus-digest:1.0" );
model.addDependency( toDependency( "junit:junit:3.8.1::jar" ) );
addModel( model );

model = toModel( "junit:junit:3.8.1" );
addModel( model );

model = toModel( "org.apache.maven.archiva:archiva-commons:1.0" );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-digest:1.0::jar" ) );
addModel( model );
}
}

+ 0
- 104
archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/WagonManagerDependencyGraphTest.java View File

@@ -1,104 +0,0 @@
package org.apache.maven.archiva.dependency.graph;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.maven.archiva.dependency.DependencyGraphFactory;
import org.apache.maven.archiva.model.DependencyScope;
import org.apache.maven.archiva.model.VersionedReference;

import java.util.ArrayList;
import java.util.List;

/**
* WagonManagerDependencyGraphTest
*
* DependencyGraphTest for testing <code>org.apache.maven.wagon:wagon-manager:2.0-SNAPSHOT</code>
*
* Generated by <code>archivadev:generate-dependency-tests</code> plugin
* @version $Id$
*/
public class WagonManagerDependencyGraphTest
extends AbstractDependencyGraphFactoryTestCase
{
public void testResolvedDepsToNodes()
throws GraphTaskException
{
MemoryRepositoryDependencyGraphBuilder graphBuilder =
new MemoryRepositoryDependencyGraphBuilder();
MemoryRepository repository = new WagonManagerMemoryRepository();
graphBuilder.setMemoryRepository( repository );

// Create the factory, and add the test resolver.
DependencyGraphFactory factory = new DependencyGraphFactory();
factory.setGraphBuilder( graphBuilder );
factory.setDesiredScope( DependencyScope.TEST );

// Get the model to resolve from
VersionedReference rootRef = toVersionedReference( "org.apache.maven.wagon:wagon-manager:2.0-SNAPSHOT");

// Perform the resolution.
DependencyGraph graph = factory.getGraph( rootRef );

// Test the results.
assertNotNull( "Graph shouldn't be null.", graph );

String expectedRootRef = "org.apache.maven.wagon:wagon-manager:2.0-SNAPSHOT";
List<String> expectedNodes = new ArrayList<String>();

// Check for all nodes, regardless of scope.
expectedNodes.clear();
expectedNodes.add( "classworlds:classworlds:1.1-alpha-2::jar" );
expectedNodes.add( "com.jcraft:jsch:0.1.27::jar" );
expectedNodes.add( "commons-httpclient:commons-httpclient:2.0.2::jar" );
expectedNodes.add( "commons-lang:commons-lang:2.1::jar" );
expectedNodes.add( "commons-logging:commons-logging:1.0.4::jar" );
expectedNodes.add( "commons-net:commons-net:1.4.1::jar" );
expectedNodes.add( "de.zeigermann.xml:xml-im-exporter:1.1::jar" );
expectedNodes.add( "it.could:webdav:0.4::jar" );
expectedNodes.add( "javax.servlet:servlet-api:2.3::jar" );
expectedNodes.add( "jdom:jdom:1.0::jar" );
expectedNodes.add( "jtidy:jtidy:4aug2000r7-dev::jar" );
expectedNodes.add( "junit:junit:3.8.1::jar" );
expectedNodes.add( "org.apache.maven.wagon:wagon-file:2.0-SNAPSHOT::jar" );
expectedNodes.add( "org.apache.maven.wagon:wagon-ftp:2.0-SNAPSHOT::jar" );
expectedNodes.add( "org.apache.maven.wagon:wagon-http-lightweight:2.0-SNAPSHOT::jar" );
expectedNodes.add( "org.apache.maven.wagon:wagon-http-shared:2.0-SNAPSHOT::jar" );
expectedNodes.add( "org.apache.maven.wagon:wagon-provider-api:2.0-SNAPSHOT::jar" );
expectedNodes.add( "org.apache.maven.wagon:wagon-ssh:2.0-SNAPSHOT::jar" );
expectedNodes.add( "org.apache.maven.wagon:wagon-ssh-common:2.0-SNAPSHOT::jar" );
expectedNodes.add( "org.apache.maven.wagon:wagon-ssh-external:2.0-SNAPSHOT::jar" );
expectedNodes.add( "org.apache.maven.wagon:wagon-webdav:2.0-SNAPSHOT::jar" );
expectedNodes.add( "org.codehaus.plexus:plexus-classworlds:1.2-alpha-7::jar" );
expectedNodes.add( "org.codehaus.plexus:plexus-component-api:1.0-alpha-16::jar" );
expectedNodes.add( "org.codehaus.plexus:plexus-container-default:1.0-alpha-9::jar" );
expectedNodes.add( "org.codehaus.plexus:plexus-interactivity-api:1.0-alpha-6::jar" );
expectedNodes.add( "org.codehaus.plexus:plexus-utils:1.4.2-SNAPSHOT::jar" );
expectedNodes.add( "org.codehaus.plexus.webdav:plexus-webdav-api:1.0-alpha-1::jar" );
expectedNodes.add( "org.codehaus.plexus.webdav:plexus-webdav-simple:1.0-alpha-1::jar" );
expectedNodes.add( "org.mortbay.jetty:jetty:6.0.2::jar" );
expectedNodes.add( "org.mortbay.jetty:jetty-util:6.0.2::jar" );
expectedNodes.add( "org.mortbay.jetty:servlet-api-2.5:6.0.2::jar" );
expectedNodes.add( "oro:oro:2.0.8::jar" );
expectedNodes.add( "slide:slide-webdavlib:2.1::jar" );

assertGraph( graph, expectedRootRef, expectedNodes );
}

}

+ 0
- 772
archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/WagonManagerMemoryRepository.java View File

@@ -1,772 +0,0 @@
package org.apache.maven.archiva.dependency.graph;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.maven.archiva.model.ArchivaProjectModel;
import org.apache.maven.archiva.model.Dependency;
import org.apache.maven.archiva.model.VersionedReference;

/**
* WagonManagerMemoryRepository
*
* MemoryRepository for testing <code>org.apache.maven.wagon:wagon-manager:2.0-SNAPSHOT</code>
*
* Generated by <code>archivadev:generate-dependency-tests</code> plugin
* @version $Id$
*/
public class WagonManagerMemoryRepository
extends AbstractMemoryRepository
{
public void initialize()
{
ArchivaProjectModel model;
Dependency dep;

model = toModel( "org.apache.maven.wagon:wagon-manager:2.0-SNAPSHOT" );
model.setParentProject( toParent( "org.apache.maven.wagon:wagon:2.0-SNAPSHOT" ) );
model.addDependency( toDependency( "junit:junit:3.8.1::jar", "test" ) );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-container-default:1.0-alpha-9::jar", "test" ) );
model.addDependency( toDependency( "org.apache.maven.wagon:wagon-provider-api:2.0-SNAPSHOT::jar" ) );
model.addDependency( toDependency( "org.apache.maven.wagon:wagon-file:2.0-SNAPSHOT::jar" ) );
model.addDependency( toDependency( "org.apache.maven.wagon:wagon-ftp:2.0-SNAPSHOT::jar", "test" ) );
model.addDependency( toDependency( "org.apache.maven.wagon:wagon-http-lightweight:2.0-SNAPSHOT::jar" ) );
model.addDependency( toDependency( "org.apache.maven.wagon:wagon-ssh:2.0-SNAPSHOT::jar" ) );
model.addDependency( toDependency( "org.apache.maven.wagon:wagon-ssh-external:2.0-SNAPSHOT::jar" ) );
model.addDependency( toDependency( "org.apache.maven.wagon:wagon-webdav:2.0-SNAPSHOT::jar", "test" ) );
dep = toDependency( "org.codehaus.plexus.webdav:plexus-webdav-simple:1.0-alpha-1::jar", "test" );
addExclusion( dep, "org.codehaus.plexus:plexus-component-api" );
model.addDependency( dep );
model.addDependency( toDependency( "org.mortbay.jetty:jetty:6.0.2::jar", "test" ) );
model.addDependencyManagement( toDependency( "org.apache.maven.wagon:wagon-provider-api:2.0-SNAPSHOT::jar" ) );
model.addDependencyManagement( toDependency( "org.apache.maven.wagon:wagon-provider-test:2.0-SNAPSHOT::jar" ) );
model.addDependencyManagement( toDependency( "org.apache.maven.wagon:wagon-ssh-common-test:2.0-SNAPSHOT::jar" ) );
model.addDependencyManagement( toDependency( "org.apache.maven.wagon:wagon-ssh-common:2.0-SNAPSHOT::jar" ) );
model.addDependencyManagement( toDependency( "junit:junit:3.8.1::jar" ) );
dep = toDependency( "org.codehaus.plexus:plexus-interactivity-api:1.0-alpha-6::jar" );
addExclusion( dep, "plexus:plexus-utils" );
addExclusion( dep, "org.codehaus.plexus:plexus-container-default" );
addExclusion( dep, "classworlds:classworlds" );
model.addDependencyManagement( dep );
model.addDependencyManagement( toDependency( "org.codehaus.plexus:plexus-container-default:1.0-alpha-9::jar", "test" ) );
model.addDependencyManagement( toDependency( "org.codehaus.plexus:plexus-utils:1.4.2-SNAPSHOT::jar" ) );
addModel( model );

model = toModel( "org.apache.maven.wagon:wagon:2.0-SNAPSHOT" );
model.setParentProject( toParent( "org.apache.maven:maven-parent:5" ) );
model.addDependency( toDependency( "junit:junit:3.8.1::jar", "test" ) );
model.addDependencyManagement( toDependency( "org.apache.maven.wagon:wagon-provider-api:2.0-SNAPSHOT::jar" ) );
model.addDependencyManagement( toDependency( "org.apache.maven.wagon:wagon-provider-test:2.0-SNAPSHOT::jar" ) );
model.addDependencyManagement( toDependency( "org.apache.maven.wagon:wagon-ssh-common-test:2.0-SNAPSHOT::jar" ) );
model.addDependencyManagement( toDependency( "org.apache.maven.wagon:wagon-ssh-common:2.0-SNAPSHOT::jar" ) );
model.addDependencyManagement( toDependency( "junit:junit:3.8.1::jar" ) );
dep = toDependency( "org.codehaus.plexus:plexus-interactivity-api:1.0-alpha-6::jar" );
addExclusion( dep, "plexus:plexus-utils" );
addExclusion( dep, "org.codehaus.plexus:plexus-container-default" );
addExclusion( dep, "classworlds:classworlds" );
model.addDependencyManagement( dep );
model.addDependencyManagement( toDependency( "org.codehaus.plexus:plexus-container-default:1.0-alpha-9::jar", "test" ) );
model.addDependencyManagement( toDependency( "org.codehaus.plexus:plexus-utils:1.4.2-SNAPSHOT::jar" ) );
addModel( model );

model = toModel( "org.apache.maven:maven-parent:5" );
model.setParentProject( toParent( "org.apache:apache:3" ) );
addModel( model );

model = toModel( "org.apache:apache:3" );
addModel( model );

model = toModel( "junit:junit:3.8.1" );
addModel( model );

model = toModel( "org.apache.maven.wagon:wagon-provider-api:2.0-SNAPSHOT" );
model.setParentProject( toParent( "org.apache.maven.wagon:wagon:2.0-SNAPSHOT" ) );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-utils:1.4.2-SNAPSHOT::jar" ) );
addModel( model );

model = toModel( "org.codehaus.plexus:plexus-utils:1.4.2-SNAPSHOT" );
model.setParentProject( toParent( "org.codehaus.plexus:plexus:1.0.11" ) );
addModel( model );

model = toModel( "org.codehaus.plexus:plexus:1.0.11" );
model.addDependency( toDependency( "junit:junit:3.8.1::jar", "test" ) );
addModel( model );

model = toModel( "org.apache.maven.wagon:wagon-provider-test:2.0-SNAPSHOT" );
addModel( model );

model = toModel( "org.apache.maven.wagon:wagon-ssh-common-test:2.0-SNAPSHOT" );
addModel( model );

model = toModel( "org.apache.maven.wagon:wagon-ssh-common:2.0-SNAPSHOT" );
model.setParentProject( toParent( "org.apache.maven.wagon:wagon-providers:2.0-SNAPSHOT" ) );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-utils:1.4.2-SNAPSHOT::jar" ) );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-interactivity-api:1.0-alpha-6::jar" ) );
addModel( model );

model = toModel( "org.apache.maven.wagon:wagon-providers:2.0-SNAPSHOT" );
model.setParentProject( toParent( "org.apache.maven.wagon:wagon:2.0-SNAPSHOT" ) );
model.addDependency( toDependency( "org.apache.maven.wagon:wagon-provider-api:2.0-SNAPSHOT::jar" ) );
model.addDependency( toDependency( "org.apache.maven.wagon:wagon-provider-test:2.0-SNAPSHOT::jar", "test" ) );
addModel( model );

model = toModel( "org.codehaus.plexus:plexus-interactivity-api:1.0-alpha-6" );
model.setParentProject( toParent( "org.codehaus.plexus:plexus-interactivity:1.0-alpha-6" ) );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-utils:1.4::jar" ) );
addModel( model );

model = toModel( "org.codehaus.plexus:plexus-interactivity:1.0-alpha-6" );
model.setParentProject( toParent( "org.codehaus.plexus:plexus-components:1.1.9" ) );
addModel( model );

model = toModel( "org.codehaus.plexus:plexus-components:1.1.9" );
model.setParentProject( toParent( "org.codehaus.plexus:plexus:1.0.10" ) );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-component-api:1.0-alpha-16::jar" ) );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-container-default:1.0-alpha-16::jar", "test" ) );
addModel( model );

model = toModel( "org.codehaus.plexus:plexus:1.0.10" );
model.addDependency( toDependency( "junit:junit:3.8.1::jar", "test" ) );
addModel( model );

model = toModel( "org.codehaus.plexus:plexus-component-api:1.0-alpha-16" );
model.setParentProject( toParent( "org.codehaus.plexus:plexus-containers:1.0-alpha-16" ) );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-classworlds:1.2-alpha-7::jar" ) );
addModel( model );

model = toModel( "org.codehaus.plexus:plexus-containers:1.0-alpha-16" );
model.setParentProject( toParent( "org.codehaus.plexus:plexus:1.0.9" ) );
model.addDependency( toDependency( "junit:junit:3.8.1::jar", "compile" ) );
model.addDependencyManagement( toDependency( "org.codehaus.plexus:plexus-classworlds:1.2-alpha-7::jar" ) );
model.addDependencyManagement( toDependency( "org.codehaus.plexus:plexus-component-api:1.0-alpha-16::jar" ) );
model.addDependencyManagement( toDependency( "org.codehaus.plexus:plexus-utils:1.3::jar" ) );
addModel( model );

model = toModel( "org.codehaus.plexus:plexus:1.0.9" );
model.addDependency( toDependency( "junit:junit:3.8.1::jar", "test" ) );
addModel( model );

model = toModel( "org.codehaus.plexus:plexus-classworlds:1.2-alpha-7" );
model.setParentProject( toParent( "org.codehaus.plexus:plexus:1.0.9" ) );
model.addDependency( toDependency( "junit:junit:3.8.1::jar", "compile" ) );
addModel( model );

model = toModel( "org.codehaus.plexus:plexus-utils:1.3" );
model.setParentProject( toParent( "org.codehaus.plexus:plexus:1.0.8" ) );
addModel( model );

model = toModel( "org.codehaus.plexus:plexus:1.0.8" );
model.addDependency( toDependency( "junit:junit:3.8.1::jar", "test" ) );
addModel( model );

model = toModel( "org.codehaus.plexus:plexus-container-default:1.0-alpha-16" );
model.setParentProject( toParent( "org.codehaus.plexus:plexus-containers:1.0-alpha-16" ) );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-component-api:1.0-alpha-16::jar" ) );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-utils:1.3::jar" ) );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-classworlds:1.2-alpha-7::jar" ) );
model.addDependency( toDependency( "jmock:jmock:1.0.1::jar", "test" ) );
addModel( model );

model = toModel( "jmock:jmock:1.0.1" );
model.addDependency( toDependency( "junit:junit:3.8.1::jar" ) );
addModel( model );

model = toModel( "org.codehaus.plexus:plexus-utils:1.4" );
model.setParentProject( toParent( "org.codehaus.plexus:plexus:1.0.9" ) );
addModel( model );

model = toModel( "org.codehaus.plexus:plexus-container-default:1.0-alpha-9" );
model.setParentProject( toParent( "org.codehaus.plexus:plexus-containers:1.0.3" ) );
model.addDependency( toDependency( "junit:junit:3.8.1::jar", "compile" ) );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-utils:1.0.4::jar" ) );
model.addDependency( toDependency( "classworlds:classworlds:1.1-alpha-2::jar" ) );
addModel( model );

model = toModel( "org.codehaus.plexus:plexus-containers:1.0.3" );
model.setParentProject( toParent( "org.codehaus.plexus:plexus:1.0.4" ) );
addModel( model );

model = toModel( "org.codehaus.plexus:plexus:1.0.4" );
model.addDependency( toDependency( "junit:junit:3.8.1::jar", "test" ) );
addModel( model );

model = toModel( "org.codehaus.plexus:plexus-utils:1.0.4" );
model.addDependency( toDependency( "junit:junit:3.8.1::jar", "test" ) );
addModel( model );

model = toModel( "classworlds:classworlds:1.1-alpha-2" );
addModel( model );

model = toModel( "org.apache.maven.wagon:wagon-file:2.0-SNAPSHOT" );
model.setParentProject( toParent( "org.apache.maven.wagon:wagon-providers:2.0-SNAPSHOT" ) );
addModel( model );

model = toModel( "org.apache.maven.wagon:wagon-ftp:2.0-SNAPSHOT" );
model.setParentProject( toParent( "org.apache.maven.wagon:wagon-providers:2.0-SNAPSHOT" ) );
model.addDependency( toDependency( "commons-net:commons-net:1.4.1::jar" ) );
dep = toDependency( "org.codehaus.plexus:plexus-ftpd:1.0-alpha-1::jar", "test" );
addExclusion( dep, "plexus:plexus-container-default" );
model.addDependency( dep );
addModel( model );

model = toModel( "commons-net:commons-net:1.4.1" );
model.addDependency( toDependency( "oro:oro:2.0.8::jar" ) );
addModel( model );

model = toModel( "oro:oro:2.0.8" );
addModel( model );

model = toModel( "org.codehaus.plexus:plexus-ftpd:1.0-alpha-1" );
model.addDependency( toDependency( "concurrent:concurrent:1.3.4::jar", "compile" ) );
model.addDependency( toDependency( "cornerstone-threads:cornerstone-threads-api:1.0::jar", "compile" ) );
model.addDependency( toDependency( "junit:junit:3.8.1::jar", "test" ) );
model.addDependency( toDependency( "cornerstone-sockets:cornerstone-sockets-api:1.0::jar", "compile" ) );
model.addDependency( toDependency( "cornerstone-connection:cornerstone-connection-impl:1.0::jar", "compile" ) );
model.addDependency( toDependency( "excalibur-pool:excalibur-pool-impl:2.0::jar", "compile" ) );
model.addDependency( toDependency( "excalibur-thread:excalibur-thread:1.1.1::jar", "compile" ) );
model.addDependency( toDependency( "cornerstone-sockets:cornerstone-sockets-impl:1.0::jar", "compile" ) );
model.addDependency( toDependency( "cornerstone-connection:cornerstone-connection-api:1.0::jar", "compile" ) );
model.addDependency( toDependency( "commons-collections:commons-collections:3.0::jar", "compile" ) );
model.addDependency( toDependency( "avalon:avalon-framework:4.1.4::jar", "compile" ) );
model.addDependency( toDependency( "cornerstone-threads:cornerstone-threads-impl:1.0::jar", "compile" ) );
model.addDependency( toDependency( "excalibur-pool:excalibur-pool-api:2.0::jar", "compile" ) );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-avalon-personality:0.13::jar", "compile" ) );
model.addDependency( toDependency( "plexus:plexus-container-default:1.0-alpha-2::jar", "compile" ) );
addModel( model );

model = toModel( "concurrent:concurrent:1.3.4" );
addModel( model );

model = toModel( "cornerstone-threads:cornerstone-threads-api:1.0" );
addModel( model );

model = toModel( "cornerstone-sockets:cornerstone-sockets-api:1.0" );
addModel( model );

model = toModel( "cornerstone-connection:cornerstone-connection-impl:1.0" );
addModel( model );

model = toModel( "excalibur-pool:excalibur-pool-impl:2.0" );
addModel( model );

model = toModel( "excalibur-thread:excalibur-thread:1.1.1" );
addModel( model );

model = toModel( "cornerstone-sockets:cornerstone-sockets-impl:1.0" );
addModel( model );

model = toModel( "cornerstone-connection:cornerstone-connection-api:1.0" );
addModel( model );

model = toModel( "commons-collections:commons-collections:3.0" );
model.addDependency( toDependency( "junit:junit:3.8.1::jar", "test" ) );
addModel( model );

model = toModel( "avalon:avalon-framework:4.1.4" );
addModel( model );

model = toModel( "cornerstone-threads:cornerstone-threads-impl:1.0" );
addModel( model );

model = toModel( "excalibur-pool:excalibur-pool-api:2.0" );
addModel( model );

model = toModel( "org.codehaus.plexus:plexus-avalon-personality:0.13" );
model.addDependency( toDependency( "junit:junit:3.8.1::jar", "test" ) );
model.addDependency( toDependency( "avalon:avalon-framework:4.1.4::jar", "compile" ) );
model.addDependency( toDependency( "plexus:plexus-container-default:1.0-alpha-2::jar", "compile" ) );
addModel( model );

model = toModel( "plexus:plexus-container-default:1.0-alpha-2" );
addModel( model );

model = toModel( "org.apache.maven.wagon:wagon-http-lightweight:2.0-SNAPSHOT" );
model.setParentProject( toParent( "org.apache.maven.wagon:wagon-providers:2.0-SNAPSHOT" ) );
model.addDependency( toDependency( "org.apache.maven.wagon:wagon-http-shared:2.0-SNAPSHOT::jar" ) );
dep = toDependency( "plexus:plexus-jetty-httpd:1.0-beta-1::jar", "test" );
addExclusion( dep, "plexus:plexus-container-default" );
model.addDependency( dep );
addModel( model );

model = toModel( "org.apache.maven.wagon:wagon-http-shared:2.0-SNAPSHOT" );
model.setParentProject( toParent( "org.apache.maven.wagon:wagon-providers:2.0-SNAPSHOT" ) );
model.addDependency( toDependency( "jtidy:jtidy:4aug2000r7-dev::jar" ) );
addModel( model );

model = toModel( "jtidy:jtidy:4aug2000r7-dev" );
addModel( model );

model = toModel( "plexus:plexus-jetty-httpd:1.0-beta-1" );
model.setParentProject( toParent( "plexus:plexus-components:1.0" ) );
model.addDependency( toDependency( "jetty:jetty:4.2.10::jar" ) );
model.addDependency( toDependency( "servletapi:servletapi:2.3::jar" ) );
addModel( model );

model = toModel( "plexus:plexus-components:1.0" );
model.setParentProject( toParent( "plexus:plexus-root:1.0" ) );
model.addDependency( toDependency( "plexus:plexus-container-default:1.0-alpha-2::jar" ) );
addModel( model );

model = toModel( "plexus:plexus-root:1.0" );
model.addDependency( toDependency( "junit:junit:3.8.1::jar", "test" ) );
addModel( model );

model = toModel( "jetty:jetty:4.2.10" );
model.addDependency( toDependency( "javax.servlet:servlet-api:2.3::jar", "runtime" ) );
addModel( model );

model = toModel( "javax.servlet:servlet-api:2.3" );
addModel( model );

model = toModel( "servletapi:servletapi:2.3" );
model.setRelocation( new VersionedReference() );
model.getRelocation().setGroupId( "javax.servlet" );
model.getRelocation().setArtifactId( "servlet-api" );
model.getRelocation().setVersion( "2.3" );
addModel( model );

model = toModel( "org.apache.maven.wagon:wagon-ssh:2.0-SNAPSHOT" );
model.setParentProject( toParent( "org.apache.maven.wagon:wagon-providers:2.0-SNAPSHOT" ) );
model.addDependency( toDependency( "com.jcraft:jsch:0.1.27::jar" ) );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-interactivity-api:1.0-alpha-6::jar" ) );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-utils:1.4.2-SNAPSHOT::jar" ) );
model.addDependency( toDependency( "org.apache.maven.wagon:wagon-ssh-common:2.0-SNAPSHOT::jar" ) );
model.addDependency( toDependency( "org.apache.maven.wagon:wagon-ssh-common-test:2.0-SNAPSHOT::jar", "test" ) );
addModel( model );

model = toModel( "com.jcraft:jsch:0.1.27" );
dep = toDependency( "com.jcraft:jzlib:1.0.7::jar" );
dep.setOptional( true );
model.addDependency( dep );
addModel( model );

model = toModel( "com.jcraft:jzlib:1.0.7" );
addModel( model );

model = toModel( "org.apache.maven.wagon:wagon-ssh-external:2.0-SNAPSHOT" );
model.setParentProject( toParent( "org.apache.maven.wagon:wagon-providers:2.0-SNAPSHOT" ) );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-utils:1.4.2-SNAPSHOT::jar" ) );
model.addDependency( toDependency( "org.apache.maven.wagon:wagon-ssh-common:2.0-SNAPSHOT::jar" ) );
model.addDependency( toDependency( "org.apache.maven.wagon:wagon-ssh-common-test:2.0-SNAPSHOT::jar", "test" ) );
addModel( model );

model = toModel( "org.apache.maven.wagon:wagon-webdav:2.0-SNAPSHOT" );
model.setParentProject( toParent( "org.apache.maven.wagon:wagon-providers:2.0-SNAPSHOT" ) );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-utils:1.4.2-SNAPSHOT::jar" ) );
model.addDependency( toDependency( "slide:slide-webdavlib:2.1::jar" ) );
model.addDependency( toDependency( "commons-logging:commons-logging:1.0.4::jar", "runtime" ) );
model.addDependency( toDependency( "it.could:webdav:0.4::jar", "test" ) );
addModel( model );

model = toModel( "slide:slide-webdavlib:2.1" );
model.addDependency( toDependency( "commons-httpclient:commons-httpclient:2.0.2::jar" ) );
model.addDependency( toDependency( "jdom:jdom:1.0::jar" ) );
model.addDependency( toDependency( "de.zeigermann.xml:xml-im-exporter:1.1::jar" ) );
addModel( model );

model = toModel( "commons-httpclient:commons-httpclient:2.0.2" );
model.addDependency( toDependency( "commons-logging:commons-logging:1.0.3::jar" ) );
addModel( model );

model = toModel( "commons-logging:commons-logging:1.0.3" );
dep = toDependency( "log4j:log4j:1.2.6::jar" );
dep.setOptional( true );
model.addDependency( dep );
dep = toDependency( "logkit:logkit:1.0.1::jar" );
dep.setOptional( true );
model.addDependency( dep );
model.addDependency( toDependency( "junit:junit:3.7::jar", "test" ) );
addModel( model );

model = toModel( "log4j:log4j:1.2.6" );
addModel( model );

model = toModel( "logkit:logkit:1.0.1" );
addModel( model );

model = toModel( "junit:junit:3.7" );
addModel( model );

model = toModel( "jdom:jdom:1.0" );
dep = toDependency( "xerces:xercesImpl:2.6.0::jar" );
dep.setOptional( true );
model.addDependency( dep );
dep = toDependency( "xml-apis:xml-apis:1.0.b2::jar" );
dep.setOptional( true );
model.addDependency( dep );
dep = toDependency( "jaxen:jaxen:1.0-FCS::jar" );
dep.setOptional( true );
model.addDependency( dep );
dep = toDependency( "saxpath:saxpath:1.0-FCS::jar" );
dep.setOptional( true );
model.addDependency( dep );
dep = toDependency( "xalan:xalan:2.5.0::jar" );
dep.setOptional( true );
model.addDependency( dep );
addModel( model );

model = toModel( "xerces:xercesImpl:2.6.0" );
addModel( model );

model = toModel( "xml-apis:xml-apis:1.0.b2" );
addModel( model );

model = toModel( "jaxen:jaxen:1.0-FCS" );
addModel( model );

model = toModel( "saxpath:saxpath:1.0-FCS" );
addModel( model );

model = toModel( "xalan:xalan:2.5.0" );
addModel( model );

model = toModel( "de.zeigermann.xml:xml-im-exporter:1.1" );
addModel( model );

model = toModel( "commons-logging:commons-logging:1.0.4" );
dep = toDependency( "log4j:log4j:1.2.6::jar" );
dep.setOptional( true );
model.addDependency( dep );
dep = toDependency( "logkit:logkit:1.0.1::jar" );
dep.setOptional( true );
model.addDependency( dep );
model.addDependency( toDependency( "junit:junit:3.7::jar", "test" ) );
dep = toDependency( "avalon-framework:avalon-framework:4.1.3::jar" );
dep.setOptional( true );
model.addDependency( dep );
addModel( model );

model = toModel( "avalon-framework:avalon-framework:4.1.3" );
addModel( model );

model = toModel( "it.could:webdav:0.4" );
model.addDependency( toDependency( "javax.servlet:servlet-api:2.3::jar", "runtime" ) );
addModel( model );

model = toModel( "org.codehaus.plexus.webdav:plexus-webdav-simple:1.0-alpha-1" );
model.setParentProject( toParent( "org.codehaus.plexus.webdav:plexus-webdav-providers-parent:1.0-alpha-1" ) );
model.addDependency( toDependency( "commons-lang:commons-lang:2.1::jar" ) );
model.addDependency( toDependency( "it.could:webdav:0.4::jar" ) );
addModel( model );

model = toModel( "org.codehaus.plexus.webdav:plexus-webdav-providers-parent:1.0-alpha-1" );
model.setParentProject( toParent( "org.codehaus.plexus.webdav:plexus-webdav-parent:1.0-alpha-1" ) );
model.addDependency( toDependency( "org.codehaus.plexus.webdav:plexus-webdav-api:1.0-alpha-1::jar" ) );
model.addDependency( toDependency( "org.codehaus.plexus.webdav:plexus-webdav-test:1.0-alpha-1::jar", "test" ) );
addModel( model );

model = toModel( "org.codehaus.plexus.webdav:plexus-webdav-parent:1.0-alpha-1" );
model.setParentProject( toParent( "org.codehaus.plexus:plexus-components:1.1.8" ) );
addModel( model );

model = toModel( "org.codehaus.plexus:plexus-components:1.1.8" );
model.setParentProject( toParent( "org.codehaus.plexus:plexus:1.0.9" ) );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-component-api:1.0-alpha-15::jar" ) );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-container-default:1.0-alpha-15::jar", "test" ) );
addModel( model );

model = toModel( "org.codehaus.plexus:plexus-component-api:1.0-alpha-15" );
model.setParentProject( toParent( "org.codehaus.plexus:plexus-containers:1.0-alpha-15" ) );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-classworlds:1.2-alpha-6::jar" ) );
addModel( model );

model = toModel( "org.codehaus.plexus:plexus-containers:1.0-alpha-15" );
model.setParentProject( toParent( "org.codehaus.plexus:plexus:1.0.9" ) );
model.addDependency( toDependency( "junit:junit:3.8.1::jar", "compile" ) );
model.addDependencyManagement( toDependency( "org.codehaus.plexus:plexus-classworlds:1.2-alpha-6::jar" ) );
model.addDependencyManagement( toDependency( "org.codehaus.plexus:plexus-component-api:1.0-alpha-15::jar" ) );
model.addDependencyManagement( toDependency( "org.codehaus.plexus:plexus-utils:1.3::jar" ) );
addModel( model );

model = toModel( "org.codehaus.plexus:plexus-classworlds:1.2-alpha-6" );
model.setParentProject( toParent( "org.codehaus.plexus:plexus:1.0.9" ) );
model.addDependency( toDependency( "junit:junit:3.8.1::jar", "compile" ) );
addModel( model );

model = toModel( "org.codehaus.plexus:plexus-container-default:1.0-alpha-15" );
model.setParentProject( toParent( "org.codehaus.plexus:plexus-containers:1.0-alpha-15" ) );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-component-api:1.0-alpha-15::jar" ) );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-utils:1.3::jar" ) );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-classworlds:1.2-alpha-6::jar" ) );
model.addDependency( toDependency( "jmock:jmock:1.0.1::jar", "test" ) );
addModel( model );

model = toModel( "org.codehaus.plexus.webdav:plexus-webdav-api:1.0-alpha-1" );
model.setParentProject( toParent( "org.codehaus.plexus.webdav:plexus-webdav-parent:1.0-alpha-1" ) );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-component-api:1.0-alpha-16::jar" ) );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-container-default:1.0-alpha-16::jar" ) );
model.addDependency( toDependency( "javax.servlet:servlet-api:2.3::jar" ) );
model.addDependency( toDependency( "commons-lang:commons-lang:2.1::jar" ) );
addModel( model );

model = toModel( "commons-lang:commons-lang:2.1" );
model.addDependency( toDependency( "junit:junit:3.8.1::jar", "test" ) );
addModel( model );

model = toModel( "org.codehaus.plexus.webdav:plexus-webdav-test:1.0-alpha-1" );
addModel( model );

model = toModel( "org.mortbay.jetty:jetty:6.0.2" );
model.setParentProject( toParent( "org.mortbay.jetty:project:6.0.2" ) );
model.addDependency( toDependency( "junit:junit:3.8.1::jar", "test" ) );
model.addDependency( toDependency( "org.mortbay.jetty:jetty-util:6.0.2::jar" ) );
model.addDependency( toDependency( "org.mortbay.jetty:servlet-api-2.5:6.0.2::jar" ) );
addModel( model );

model = toModel( "org.mortbay.jetty:project:6.0.2" );
model.addDependencyManagement( toDependency( "org.apache.maven:maven-plugin-tools-api:2.0::jar" ) );
model.addDependencyManagement( toDependency( "junit:junit:3.8.1::jar" ) );
model.addDependencyManagement( toDependency( "org.slf4j:jcl104-over-slf4j:1.0.1::jar" ) );
model.addDependencyManagement( toDependency( "org.slf4j:slf4j-simple:1.0.1::jar" ) );
model.addDependencyManagement( toDependency( "mx4j:mx4j:3.0.1::jar" ) );
model.addDependencyManagement( toDependency( "mx4j:mx4j-tools:3.0.1::jar" ) );
model.addDependencyManagement( toDependency( "xerces:xercesImpl:${xerces-version}::jar" ) );
model.addDependencyManagement( toDependency( "commons-el:commons-el:1.0::jar" ) );
model.addDependencyManagement( toDependency( "ant:ant:1.6.5::jar" ) );
model.addDependencyManagement( toDependency( "javax.mail:mail:1.4::jar" ) );
model.addDependencyManagement( toDependency( "javax.activation:activation:1.1::jar" ) );
model.addProperty( "jasper-version", "5.5.15" );
model.addProperty( "junit-version", "3.8.1" );
model.addProperty( "ant-version", "1.6.5" );
model.addProperty( "mail-version", "1.4" );
model.addProperty( "commons-el-version", "1.0" );
model.addProperty( "slf4j-version", "1.0.1" );
model.addProperty( "eclipse-compiler-version", "3.1.1" );
model.addProperty( "mx4j-version", "3.0.1" );
model.addProperty( "jta-spec-version", "1.0.1B-rc4" );
model.addProperty( "activation-version", "1.1" );
addModel( model );

model = toModel( "org.apache.maven:maven-plugin-tools-api:2.0" );
model.setParentProject( toParent( "org.apache.maven:maven-plugin-tools:2.0" ) );
model.addDependency( toDependency( "org.apache.maven:maven-project:2.0::jar" ) );
model.addDependency( toDependency( "org.apache.maven:maven-plugin-descriptor:2.0::jar" ) );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-utils:1.0.4::jar" ) );
addModel( model );

model = toModel( "org.apache.maven:maven-plugin-tools:2.0" );
model.setParentProject( toParent( "org.apache.maven:maven:2.0" ) );
addModel( model );

model = toModel( "org.apache.maven:maven:2.0" );
model.addDependency( toDependency( "junit:junit:3.8.1::jar", "test" ) );
model.addDependencyManagement( toDependency( "org.codehaus.plexus:plexus-container-default:1.0-alpha-8::jar" ) );
model.addDependencyManagement( toDependency( "org.codehaus.plexus:plexus-utils:1.0.4::jar" ) );
model.addDependencyManagement( toDependency( "org.apache.maven.wagon:wagon-provider-api:1.0-alpha-5::jar" ) );
model.addDependencyManagement( toDependency( "org.apache.maven.wagon:wagon-ssh:1.0-alpha-5::jar" ) );
model.addDependencyManagement( toDependency( "org.apache.maven.wagon:wagon-file:1.0-alpha-5::jar" ) );
model.addDependencyManagement( toDependency( "org.apache.maven.wagon:wagon-http-lightweight:1.0-alpha-5::jar" ) );
addModel( model );

model = toModel( "org.codehaus.plexus:plexus-container-default:1.0-alpha-8" );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-utils:1.0.4::jar", "compile" ) );
model.addDependency( toDependency( "junit:junit:3.8.1::jar", "compile" ) );
model.addDependency( toDependency( "classworlds:classworlds:1.1-alpha-2::jar", "compile" ) );
addModel( model );

model = toModel( "org.apache.maven.wagon:wagon-provider-api:1.0-alpha-5" );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-utils:1.0.4::jar", "compile" ) );
model.addDependency( toDependency( "junit:junit:3.8.1::jar", "test" ) );
addModel( model );

model = toModel( "org.apache.maven.wagon:wagon-ssh:1.0-alpha-5" );
model.addDependency( toDependency( "com.jcraft:jsch:0.1.23::jar", "compile" ) );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-utils:1.0.4::jar", "compile" ) );
model.addDependency( toDependency( "junit:junit:3.8.1::jar", "test" ) );
model.addDependency( toDependency( "org.apache.maven.wagon:wagon-provider-api:1.0-alpha-5::jar", "compile" ) );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-container-default:1.0-alpha-8::jar", "compile" ) );
model.addDependency( toDependency( "classworlds:classworlds:1.1-alpha-2::jar", "compile" ) );
model.addDependency( toDependency( "plexus:plexus-utils:1.0.2::jar", "compile" ) );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-interactivity-api:1.0-alpha-4::jar", "compile" ) );
model.addDependency( toDependency( "org.apache.maven.wagon:wagon-provider-test:1.0-alpha-5::jar", "test" ) );
addModel( model );

model = toModel( "com.jcraft:jsch:0.1.23" );
addModel( model );

model = toModel( "plexus:plexus-utils:1.0.2" );
model.setParentProject( toParent( "plexus:plexus-root:1.0.3" ) );
addModel( model );

model = toModel( "plexus:plexus-root:1.0.3" );
model.addDependency( toDependency( "junit:junit:3.8.1::jar", "test" ) );
addModel( model );

model = toModel( "org.codehaus.plexus:plexus-interactivity-api:1.0-alpha-4" );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-container-default:1.0-alpha-7::jar", "compile" ) );
model.addDependency( toDependency( "junit:junit:3.8.1::jar", "test" ) );
model.addDependency( toDependency( "classworlds:classworlds:1.1-alpha-2::jar", "compile" ) );
model.addDependency( toDependency( "plexus:plexus-utils:1.0.2::jar", "compile" ) );
addModel( model );

model = toModel( "org.codehaus.plexus:plexus-container-default:1.0-alpha-7" );
model.setParentProject( toParent( "plexus:plexus-containers:1.0.2" ) );
model.addDependency( toDependency( "junit:junit:3.8.1::jar", "compile" ) );
model.addDependency( toDependency( "plexus:plexus-utils:1.0.2::jar" ) );
model.addDependency( toDependency( "classworlds:classworlds:1.1-alpha-2::jar" ) );
addModel( model );

model = toModel( "plexus:plexus-containers:1.0.2" );
model.setParentProject( toParent( "plexus:plexus-root:1.0.3" ) );
addModel( model );

model = toModel( "org.apache.maven.wagon:wagon-provider-test:1.0-alpha-5" );
addModel( model );

model = toModel( "org.apache.maven.wagon:wagon-file:1.0-alpha-5" );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-utils:1.0.4::jar", "compile" ) );
model.addDependency( toDependency( "junit:junit:3.8.1::jar", "test" ) );
model.addDependency( toDependency( "org.apache.maven.wagon:wagon-provider-api:1.0-alpha-5::jar", "compile" ) );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-container-default:1.0-alpha-8::jar", "test" ) );
model.addDependency( toDependency( "classworlds:classworlds:1.1-alpha-2::jar", "test" ) );
model.addDependency( toDependency( "org.apache.maven.wagon:wagon-provider-test:1.0-alpha-5::jar", "test" ) );
addModel( model );

model = toModel( "org.apache.maven.wagon:wagon-http-lightweight:1.0-alpha-5" );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-utils:1.0.4::jar", "compile" ) );
model.addDependency( toDependency( "junit:junit:3.8.1::jar", "test" ) );
model.addDependency( toDependency( "org.apache.maven.wagon:wagon-provider-api:1.0-alpha-5::jar", "compile" ) );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-container-default:1.0-alpha-8::jar", "test" ) );
model.addDependency( toDependency( "servletapi:servletapi:2.3::jar", "test" ) );
model.addDependency( toDependency( "classworlds:classworlds:1.1-alpha-2::jar", "test" ) );
model.addDependency( toDependency( "jetty:jetty:4.2.10::jar", "test" ) );
model.addDependency( toDependency( "plexus:plexus-jetty-httpd:1.0-beta-1::jar", "test" ) );
model.addDependency( toDependency( "org.apache.maven.wagon:wagon-provider-test:1.0-alpha-5::jar", "test" ) );
addModel( model );

model = toModel( "org.apache.maven:maven-project:2.0" );
model.setParentProject( toParent( "org.apache.maven:maven:2.0" ) );
model.addDependency( toDependency( "org.apache.maven:maven-artifact-test:2.0::jar", "test" ) );
model.addDependency( toDependency( "org.apache.maven:maven-profile:2.0::jar" ) );
model.addDependency( toDependency( "org.apache.maven:maven-model:2.0::jar" ) );
model.addDependency( toDependency( "org.apache.maven:maven-artifact-manager:2.0::jar" ) );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-utils:1.0.4::jar" ) );
model.addDependency( toDependency( "org.apache.maven:maven-artifact:2.0::jar" ) );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-container-default:1.0-alpha-8::jar" ) );
addModel( model );

model = toModel( "org.apache.maven:maven-artifact-test:2.0" );
addModel( model );

model = toModel( "org.apache.maven:maven-profile:2.0" );
model.setParentProject( toParent( "org.apache.maven:maven:2.0" ) );
model.addDependency( toDependency( "org.apache.maven:maven-model:2.0::jar" ) );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-utils:1.0.4::jar" ) );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-container-default:1.0-alpha-8::jar" ) );
addModel( model );

model = toModel( "org.apache.maven:maven-model:2.0" );
model.setParentProject( toParent( "org.apache.maven:maven:2.0" ) );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-utils:1.0.4::jar" ) );
addModel( model );

model = toModel( "org.apache.maven:maven-artifact-manager:2.0" );
model.setParentProject( toParent( "org.apache.maven:maven:2.0" ) );
model.addDependency( toDependency( "org.apache.maven:maven-repository-metadata:2.0::jar" ) );
model.addDependency( toDependency( "org.apache.maven.wagon:wagon-file:1.0-alpha-5::jar", "test" ) );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-utils:1.0.4::jar" ) );
model.addDependency( toDependency( "org.apache.maven:maven-artifact:2.0::jar" ) );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-container-default:1.0-alpha-8::jar" ) );
model.addDependency( toDependency( "org.apache.maven.wagon:wagon-provider-api:1.0-alpha-5::jar" ) );
addModel( model );

model = toModel( "org.apache.maven:maven-repository-metadata:2.0" );
model.setParentProject( toParent( "org.apache.maven:maven:2.0" ) );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-utils:1.0.4::jar" ) );
addModel( model );

model = toModel( "org.apache.maven:maven-artifact:2.0" );
model.setParentProject( toParent( "org.apache.maven:maven:2.0" ) );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-utils:1.0.4::jar" ) );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-container-default:1.0-alpha-8::jar", "test" ) );
addModel( model );

model = toModel( "org.apache.maven:maven-plugin-descriptor:2.0" );
model.setParentProject( toParent( "org.apache.maven:maven:2.0" ) );
model.addDependency( toDependency( "org.apache.maven:maven-plugin-api:2.0::jar" ) );
model.addDependency( toDependency( "org.apache.maven:maven-artifact:2.0::jar" ) );
model.addDependency( toDependency( "org.codehaus.plexus:plexus-container-default:1.0-alpha-8::jar" ) );
addModel( model );

model = toModel( "org.apache.maven:maven-plugin-api:2.0" );
model.setParentProject( toParent( "org.apache.maven:maven:2.0" ) );
model.addDependency( toDependency( "junit:junit:3.8.1::jar", "test" ) );
addModel( model );

model = toModel( "org.slf4j:jcl104-over-slf4j:1.0.1" );
addModel( model );

model = toModel( "org.slf4j:slf4j-simple:1.0.1" );
addModel( model );

model = toModel( "mx4j:mx4j:3.0.1" );
addModel( model );

model = toModel( "mx4j:mx4j-tools:3.0.1" );
addModel( model );

model = toModel( "xerces:xercesImpl:${xerces-version}" );
addModel( model );

model = toModel( "commons-el:commons-el:1.0" );
model.addDependency( toDependency( "servletapi:servletapi:2.4-20040521::jar", "provided" ) );
model.addDependency( toDependency( "jspapi:jsp-api:2.0-20040521::jar", "provided" ) );
model.addDependency( toDependency( "commons-logging:commons-logging:1.0.3::jar" ) );
addModel( model );

model = toModel( "servletapi:servletapi:2.4-20040521" );
addModel( model );

model = toModel( "jspapi:jsp-api:2.0-20040521" );
addModel( model );

model = toModel( "ant:ant:1.6.5" );
dep = toDependency( "xerces:xerces-impl:2.6.2::jar" );
dep.setOptional( true );
model.addDependency( dep );
dep = toDependency( "xml-apis:xml-apis:2.6.2::jar" );
dep.setOptional( true );
model.addDependency( dep );
addModel( model );

model = toModel( "xerces:xerces-impl:2.6.2" );
addModel( model );

model = toModel( "xml-apis:xml-apis:2.6.2" );
addModel( model );

model = toModel( "javax.mail:mail:1.4" );
model.addDependency( toDependency( "javax.activation:activation:1.1::jar" ) );
addModel( model );

model = toModel( "javax.activation:activation:1.1" );
addModel( model );

model = toModel( "org.mortbay.jetty:jetty-util:6.0.2" );
model.setParentProject( toParent( "org.mortbay.jetty:project:6.0.2" ) );
model.addDependency( toDependency( "junit:junit:3.8.1::jar", "test" ) );
model.addDependency( toDependency( "org.mortbay.jetty:servlet-api-2.5:6.0.2::jar", "provided" ) );
addModel( model );

model = toModel( "org.mortbay.jetty:servlet-api-2.5:6.0.2" );
model.setParentProject( toParent( "org.mortbay.jetty:project:6.0.2" ) );
addModel( model );

}
}

+ 0
- 66
archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/functors/ToKeyTransformer.java View File

@@ -1,66 +0,0 @@
package org.apache.maven.archiva.dependency.graph.functors;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.commons.collections.Transformer;
import org.apache.maven.archiva.dependency.graph.DependencyGraphEdge;
import org.apache.maven.archiva.dependency.graph.DependencyGraphKeys;
import org.apache.maven.archiva.dependency.graph.DependencyGraphNode;
import org.apache.maven.archiva.model.ArchivaProjectModel;
import org.apache.maven.archiva.model.ArtifactReference;
import org.apache.maven.archiva.model.Keys;

/**
* ToKeyTransformer
*
* @version $Id$
*/
public class ToKeyTransformer
implements Transformer
{

public Object transform( Object input )
{
if ( input instanceof ArchivaProjectModel )
{
return Keys.toKey( (ArchivaProjectModel) input );
}

if ( input instanceof DependencyGraphNode )
{
return DependencyGraphKeys.toKey( ((DependencyGraphNode) input).getArtifact() );
}

if ( input instanceof DependencyGraphEdge )
{
DependencyGraphEdge edge = (DependencyGraphEdge) input;
// Potentially Confusing, but this is called "To"KeyTransformer after all.
return DependencyGraphKeys.toKey( edge.getNodeTo() );
}

if ( input instanceof ArtifactReference )
{
return DependencyGraphKeys.toKey( ((ArtifactReference) input) );
}

return input;
}

}

+ 0
- 225
archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/tasks/DependencyManagementStackTest.java View File

@@ -1,225 +0,0 @@
package org.apache.maven.archiva.dependency.graph.tasks;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.commons.lang.StringUtils;
import org.apache.maven.archiva.dependency.graph.DependencyGraphNode;
import org.apache.maven.archiva.dependency.graph.tasks.DependencyManagementStack.Rules;
import org.apache.maven.archiva.model.ArtifactReference;
import org.apache.maven.archiva.model.Dependency;

import junit.framework.TestCase;

/**
* DependencyManagementStackTest
*
* @version $Id$
*/
public class DependencyManagementStackTest
extends TestCase
{
public DependencyGraphNode toNode( String key )
{
String parts[] = StringUtils.splitPreserveAllTokens( key, ":" );
assertEquals( "toNode(" + key + ") requires 5 parts", 5, parts.length );

ArtifactReference ref = new ArtifactReference();
ref.setGroupId( parts[0] );
ref.setArtifactId( parts[1] );
ref.setVersion( parts[2] );
ref.setClassifier( parts[3] );
ref.setType( parts[4] );

return new DependencyGraphNode( ref );
}

protected Dependency toDependency( String key )
{
String parts[] = StringUtils.splitPreserveAllTokens( key, ':' );

assertEquals( "Dependency key [" + key + "] should be 5 parts.", 5, parts.length );

Dependency dep = new Dependency();

dep.setGroupId( parts[0] );
dep.setArtifactId( parts[1] );
dep.setVersion( parts[2] );
dep.setClassifier( parts[3] );
dep.setType( parts[4] );

return dep;
}

public void testPushPopSimple()
{
DependencyGraphNode node = toNode( "org.apache.maven.archiva:depmanstack-testcase:1.0::jar" );
Dependency dep = toDependency( "junit:junit:3.8.1::jar" );
dep.setScope( "test" );
node.addDependencyManagement( dep );

DependencyManagementStack stack = new DependencyManagementStack();
stack.push( node );
DependencyGraphNode oldnode = stack.pop();
assertEquals( "added node to old node", node, oldnode );
}

public void testPushPopTwoDeep()
{
DependencyManagementStack stack = new DependencyManagementStack();
Dependency dep;

// top node.
DependencyGraphNode projectNode = toNode( "org.apache.maven.archiva:depmanstack-testcase:1.0::jar" );
dep = toDependency( "junit:junit:3.8.1::jar" );
dep.setScope( "test" );
projectNode.addDependencyManagement( dep );
stack.push( projectNode );

// direct node.
DependencyGraphNode directNode = toNode( "org.apache.maven.archiva:depmanstack-common:1.0::jar" );
dep = toDependency( "junit:junit:3.7::jar" );
dep.setScope( "test" );
directNode.addDependencyManagement( dep );
stack.push( directNode );

// transitive node.
DependencyGraphNode transNode = toNode( "org.apache.maven.archiva:depmanstack-model:1.0::jar" );
dep = toDependency( "junit:junit:3.7::jar" );
transNode.addDependencyManagement( dep );
stack.push( transNode );

// Test it
assertEquals( "popped node is trans node", transNode, stack.pop() );
assertEquals( "popped node is direct node", directNode, stack.pop() );
assertEquals( "popped node is project node", projectNode, stack.pop() );
}

public void testApplyNodeVersionParentWins()
{
DependencyManagementStack stack = new DependencyManagementStack();
Dependency dep;

// top node.
DependencyGraphNode projectNode = toNode( "org.apache.maven.archiva:depmanstack-testcase:1.0::jar" );
dep = toDependency( "junit:junit:3.8.1::jar" );
dep.setScope( "test" );
projectNode.addDependencyManagement( dep );
stack.push( projectNode );

// direct node.
DependencyGraphNode directNode = toNode( "org.apache.maven.archiva:depmanstack-common:1.0::jar" );
dep = toDependency( "junit:junit:3.7::jar" );
dep.setScope( "test" );
directNode.addDependencyManagement( dep );
stack.push( directNode );

// transitive node.
DependencyGraphNode transNode = toNode( "org.apache.maven.archiva:depmanstack-model:1.0::jar" );
dep = toDependency( "junit:junit:3.7.1::jar" );
transNode.addDependencyManagement( dep );
stack.push( transNode );

// Test it
DependencyGraphNode junitNode = toNode( "junit:junit:1.0::jar" );

assertRules( "junit (lvl:trans)", stack, junitNode, "3.8.1", "test", null );
stack.pop();
assertRules( "junit (lvl:direct)", stack, junitNode, "3.8.1", "test", null );
stack.pop();
assertRules( "junit (lvl:project)", stack, junitNode, "3.8.1", "test", null );
}

/**
* This test is based off of Carlos Sanchez's depman example use case.
*
* In a simple project chain of A:1.0 -&gt; B:1.0 -&gt; C:1.0 -&gt; D:1.0
* If B:1.0 has a dependency management section stating dep D should be version 2.0
* Then the dep D when viewed from A should be version 2.0
*/
public void testApplyNodeVersionCarlosABCD()
{
DependencyManagementStack stack = new DependencyManagementStack();
Dependency dep;

// project node, A
DependencyGraphNode nodeA = toNode( "org.apache.maven.archiva:carlos-A:1.0::jar" );
stack.push( nodeA );

// sub node, B
DependencyGraphNode nodeB = toNode( "org.apache.maven.archiva:carlos-B:1.0::jar" );
dep = toDependency( "org.apache.maven.archiva:carlos-D:2.0::jar" );
nodeB.addDependencyManagement( dep );
stack.push( nodeB );

// sub node, C
DependencyGraphNode nodeC = toNode( "org.apache.maven.archiva:carlos-C:1.0::jar" );
stack.push( nodeC );

// sub node, D
// Not added to the stack, as this is the node that is having the rules applied to it.
DependencyGraphNode nodeD = toNode( "org.apache.maven.archiva:carlos-D:1.0::jar" );

// Test it
assertRules( "node D (lvl:C)", stack, nodeD, "2.0", null, null );
stack.pop();
assertRules( "node D (lvl:B)", stack, nodeD, "2.0", null, null );
stack.pop();
assertNoRules( "node D (lvl:A)", stack, nodeD, "2.0", null, null );
}

/**
* Test for expected rules, that should be enforced for the provided node.
* NOTE: This test will update the node.artifact.version to whatever is stated in the rules.
*/
private void assertRules( String msg, DependencyManagementStack stack, DependencyGraphNode node,
String expectedVersion, String expectedScope, String expectedExclusions[] )
{
Rules rules = stack.getRules( node );
assertNotNull( msg + " rules should not be null.", rules );

node.getArtifact().setVersion( rules.artifact.getVersion() );

assertEquals( msg + ": version", expectedVersion, rules.artifact.getVersion() );
assertEquals( msg + ": scope", expectedScope, rules.scope );

if ( expectedExclusions != null )
{
// TODO: test for exclusion settings.
}
}

/**
* Test for when there are no rules being enforced for the provided node.
* Similar to assertRules() above.
*/
private void assertNoRules( String msg, DependencyManagementStack stack, DependencyGraphNode node,
String expectedVersion, String expectedScope, String expectedExclusions[] )
{
Rules rules = stack.getRules( node );
assertNull( msg + " rules should be null.", rules );

assertEquals( msg + ": version", expectedVersion, node.getArtifact().getVersion() );

if ( expectedExclusions != null )
{
// TODO: test for exclusion settings.
}
}
}

+ 0
- 228
archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/walk/DependencyGraphWalkerTest.java View File

@@ -1,228 +0,0 @@
package org.apache.maven.archiva.dependency.graph.walk;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.commons.lang.StringUtils;
import org.apache.maven.archiva.dependency.graph.DependencyGraph;
import org.apache.maven.archiva.dependency.graph.DependencyGraphEdge;
import org.apache.maven.archiva.dependency.graph.DependencyGraphKeys;
import org.apache.maven.archiva.dependency.graph.DependencyGraphNode;
import org.apache.maven.archiva.dependency.graph.tasks.FlagCyclicEdgesTask;
import org.apache.maven.archiva.model.ArtifactReference;

import java.util.List;

import junit.framework.TestCase;

/**
* DependencyGraphWalkerTest
*
* @version $Id$
*/
public class DependencyGraphWalkerTest
extends TestCase
{
/**
* <pre>
* [foo-util] ---&gt; [foo-common]
* \
* ---------&gt; [foo-xml] ---&gt; [xercesImpl] ---&gt; [xmlParserAPIs]
* \ \
* \ ---&gt; [jdom] ----+
* \ |
* ----&gt; [jaxen] &lt;--+
* </pre>
*/
public void testModerateWalk()
{
DependencyGraph graph = new DependencyGraph( "org.foo", "foo-util", "1.0" );
String rootKey = DependencyGraphKeys.toKey( graph.getRootNode().getArtifact() );
addEdgeAndNodes( graph, toEdge( rootKey, "org.foo:foo-common:1.0::jar" ) );
addEdgeAndNodes( graph, toEdge( rootKey, "org.foo:foo-xml:1.0::jar" ) );

addEdgeAndNodes( graph, toEdge( "org.foo:foo-xml:1.0::jar", "xerces:xercesImpl:2.2.1::jar" ) );
addEdgeAndNodes( graph, toEdge( "xerces:xercesImpl:2.2.1::jar", "xerces:xmlParserAPIs:2.2.1::jar" ) );
addEdgeAndNodes( graph, toEdge( "org.foo:foo-xml:1.0::jar", "jdom:jdom:1.0::jar" ) );
addEdgeAndNodes( graph, toEdge( "org.foo:foo-xml:1.0::jar", "jaxen:jaxen:1.0::jar" ) );
addEdgeAndNodes( graph, toEdge( "jdom:jdom:1.0::jar", "jaxen:jaxen:1.0::jar" ) );

DependencyGraphWalker walker = new WalkDepthFirstSearch();
WalkCollector walkCollector = new WalkCollector();
walker.visit( graph, walkCollector );

String expectedPath[] = new String[] {
rootKey,
"org.foo:foo-common:1.0::jar",
"org.foo:foo-xml:1.0::jar",
"jaxen:jaxen:1.0::jar",
"xerces:xercesImpl:2.2.1::jar",
"xerces:xmlParserAPIs:2.2.1::jar",
"jdom:jdom:1.0::jar" };

assertVisitor( walkCollector, 1, 7, 7 );
assertPath( expectedPath, walkCollector.getCollectedPath() );
}

/**
* <pre>
* [foo-util] ---&gt; [foo-common]
* \
* ---------&gt; [foo-xml] ---&gt; [xercesImpl] ---&gt; [xmlParserAPIs]
* </pre>
*/
public void testSimpleWalk()
{
DependencyGraph graph = new DependencyGraph( "org.foo", "foo-util", "1.0" );
String rootKey = DependencyGraphKeys.toKey( graph.getRootNode().getArtifact() );
addEdgeAndNodes( graph, toEdge( rootKey, "org.foo:foo-common:1.0::jar" ) );
addEdgeAndNodes( graph, toEdge( rootKey, "org.foo:foo-xml:1.0::jar" ) );
addEdgeAndNodes( graph, toEdge( "org.foo:foo-xml:1.0::jar", "xerces:xercesImpl:2.2.1::jar" ) );
addEdgeAndNodes( graph, toEdge( "xerces:xercesImpl:2.2.1::jar", "xerces:xmlParserAPIs:2.2.1::jar" ) );

DependencyGraphWalker walker = new WalkDepthFirstSearch();
WalkCollector walkCollector = new WalkCollector();
walker.visit( graph, walkCollector );

String expectedPath[] = new String[] {
rootKey,
"org.foo:foo-common:1.0::jar",
"org.foo:foo-xml:1.0::jar",
"xerces:xercesImpl:2.2.1::jar",
"xerces:xmlParserAPIs:2.2.1::jar" };

assertVisitor( walkCollector, 1, 5, 4 );
assertPath( expectedPath, walkCollector.getCollectedPath() );
}

/**
* <pre>
* [foo-util] ---&gt; [foo-common]
* \
* \ +----------------------------------------+
* \ v |
* -------&gt; [foo-xml] ---&gt; [xercesImpl] ---&gt; [xmlParserAPIs]
* \ \
* \ ---&gt; [jdom] ----+
* \ |
* ----&gt; [jaxen] &lt;--+
* </pre>
*/
public void testDeepNodeWalk()
{
DependencyGraph graph = new DependencyGraph( "org.foo", "foo-util", "1.0" );
String rootKey = DependencyGraphKeys.toKey( graph.getRootNode().getArtifact() );
addEdgeAndNodes( graph, toEdge( rootKey, "org.foo:foo-common:1.0::jar" ) );
addEdgeAndNodes( graph, toEdge( rootKey, "org.foo:foo-xml:1.0::jar" ) );

addEdgeAndNodes( graph, toEdge( "org.foo:foo-xml:1.0::jar", "xerces:xercesImpl:2.2.1::jar" ) );
addEdgeAndNodes( graph, toEdge( "xerces:xercesImpl:2.2.1::jar", "xerces:xmlParserAPIs:2.2.1::jar" ) );
addEdgeAndNodes( graph, toEdge( "org.foo:foo-xml:1.0::jar", "jdom:jdom:1.0::jar" ) );
addEdgeAndNodes( graph, toEdge( "org.foo:foo-xml:1.0::jar", "jaxen:jaxen:1.0::jar" ) );
addEdgeAndNodes( graph, toEdge( "jdom:jdom:1.0::jar", "jaxen:jaxen:1.0::jar" ) );
// introduce cyclic dep. intentional. should only result in walking to foo-xml once.
addEdgeAndNodes( graph, toEdge( "xerces:xmlParserAPIs:2.2.1::jar", "org.foo:foo-xml:1.0::jar" ) );

new FlagCyclicEdgesTask().executeTask( graph );

DependencyGraphWalker walker = new WalkDepthFirstSearch();
WalkCollector walkCollector = new WalkCollector();
ArtifactReference startRef = toArtifactReference( "org.foo:foo-xml:1.0::jar" );
DependencyGraphNode startNode = new DependencyGraphNode( startRef );
walker.visit( graph, startNode, walkCollector );

String expectedPath[] = new String[] {
"org.foo:foo-xml:1.0::jar",
"jaxen:jaxen:1.0::jar",
"xerces:xercesImpl:2.2.1::jar",
"xerces:xmlParserAPIs:2.2.1::jar",
"jdom:jdom:1.0::jar" };

assertVisitor( walkCollector, 1, 5, 6 );
assertPath( expectedPath, walkCollector.getCollectedPath() );
}

private void addEdgeAndNodes( DependencyGraph graph, DependencyGraphEdge edge )
{
ensureNodeExists( graph, edge.getNodeFrom() );
ensureNodeExists( graph, edge.getNodeTo() );
graph.addEdge( edge );
}

private void ensureNodeExists( DependencyGraph graph, ArtifactReference artifact )
{
DependencyGraphNode node = graph.getNode( artifact );
if ( node == null )
{
node = new DependencyGraphNode( artifact );
graph.addNode( node );
}
}

private void assertPath( String[] expectedPath, List<String> collectedPath )
{
assertEquals( "Path.length", expectedPath.length, collectedPath.size() );

for ( int i = 0; i < expectedPath.length; i++ )
{
assertEquals( "Walk path[" + i + "]", expectedPath[i], collectedPath.get( i ) );
}
}

private void assertVisitor( WalkCollector walkCollector, int countGraphs, int countNodes, int countEdges )
{
assertEquals( "Count of graph discovery.", countGraphs, walkCollector.getCountDiscoverGraph() );
assertEquals( "Count of graph finished.", countGraphs, walkCollector.getCountFinishGraph() );
assertEquals( "Discover - Finish = 0 (on graph counts)", 0,
( walkCollector.getCountDiscoverGraph() - walkCollector.getCountFinishGraph() ) );

assertEquals( "Count of node discovery.", countNodes, walkCollector.getCountDiscoverNode() );
assertEquals( "Count of node finished.", countNodes, walkCollector.getCountFinishNode() );
assertEquals( "Discover - Finish = 0 (on node counts)", 0,
( walkCollector.getCountDiscoverNode() - walkCollector.getCountFinishNode() ) );

assertEquals( "Count of edge discovery.", countEdges, walkCollector.getCountDiscoverEdge() );
assertEquals( "Count of edge finished.", countEdges, walkCollector.getCountFinishEdge() );
assertEquals( "Discover - Finish = 0 (on edge counts)", 0,
( walkCollector.getCountDiscoverEdge() - walkCollector.getCountFinishEdge() ) );
}

private DependencyGraphEdge toEdge( String fromKey, String toKey )
{
ArtifactReference nodeFrom = toArtifactReference( fromKey );
ArtifactReference nodeTo = toArtifactReference( toKey );

return new DependencyGraphEdge( nodeFrom, nodeTo );
}

private ArtifactReference toArtifactReference( String key )
{
String parts[] = StringUtils.splitPreserveAllTokens( key, ':' );
assertEquals( "ArtifactReference [" + key + "] parts should equal 5", 5, parts.length );

ArtifactReference artifact = new ArtifactReference();
artifact.setGroupId( parts[0] );
artifact.setArtifactId( parts[1] );
artifact.setVersion( parts[2] );
artifact.setClassifier( parts[3] );
artifact.setType( parts[4] );

return artifact;
}
}

+ 0
- 113
archiva-modules/archiva-base/archiva-dependency-graph/src/test/java/org/apache/maven/archiva/dependency/graph/walk/WalkCollector.java View File

@@ -1,113 +0,0 @@
package org.apache.maven.archiva.dependency.graph.walk;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.maven.archiva.dependency.graph.DependencyGraph;
import org.apache.maven.archiva.dependency.graph.DependencyGraphEdge;
import org.apache.maven.archiva.dependency.graph.DependencyGraphNode;
import org.apache.maven.archiva.model.ArtifactReference;

import java.util.ArrayList;
import java.util.List;

class WalkCollector
implements DependencyGraphVisitor
{
private List<String> walkPath = new ArrayList<String>();

private int countDiscoverGraph = 0;

private int countFinishGraph = 0;

private int countDiscoverNode = 0;

private int countFinishNode = 0;

private int countDiscoverEdge = 0;

private int countFinishEdge = 0;

public void discoverEdge( DependencyGraphEdge edge )
{
countDiscoverEdge++;
}

public void discoverGraph( DependencyGraph graph )
{
countDiscoverGraph++;
}

public void discoverNode( DependencyGraphNode node )
{
countDiscoverNode++;
walkPath.add( ArtifactReference.toKey( node.getArtifact() ) );
}

public void finishEdge( DependencyGraphEdge edge )
{
countFinishEdge++;
}

public void finishGraph( DependencyGraph graph )
{
countFinishGraph++;
}

public void finishNode( DependencyGraphNode node )
{
countFinishNode++;
}

public List<String> getCollectedPath()
{
return walkPath;
}

public int getCountDiscoverEdge()
{
return countDiscoverEdge;
}

public int getCountDiscoverGraph()
{
return countDiscoverGraph;
}

public int getCountDiscoverNode()
{
return countDiscoverNode;
}

public int getCountFinishEdge()
{
return countFinishEdge;
}

public int getCountFinishGraph()
{
return countFinishGraph;
}

public int getCountFinishNode()
{
return countFinishNode;
}

}

+ 0
- 1
archiva-modules/archiva-base/pom.xml View File

@@ -38,7 +38,6 @@
<module>archiva-consumers</module>
<module>archiva-indexer</module>
<module>archiva-model</module>
<module>archiva-dependency-graph</module>
<module>archiva-repository-layer</module>
<module>archiva-xml-tools</module>
<module>archiva-proxy</module>

+ 0
- 4
archiva-modules/archiva-web/archiva-webapp/pom.xml View File

@@ -29,10 +29,6 @@
<packaging>war</packaging>
<name>Archiva Web :: Application</name>
<dependencies>
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-dependency-graph</artifactId>
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-report-manager</artifactId>

+ 69
- 121
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/DependencyTree.java View File

@@ -23,63 +23,54 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Stack;

import javax.servlet.jsp.PageContext;
import com.opensymphony.xwork2.ActionContext;
import org.apache.archiva.dependency.tree.maven2.DependencyTreeBuilder;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.archiva.common.ArchivaException;
import org.apache.maven.archiva.dependency.DependencyGraphFactory;
import org.apache.maven.archiva.dependency.graph.DependencyGraph;
import org.apache.maven.archiva.dependency.graph.DependencyGraphBuilder;
import org.apache.maven.archiva.dependency.graph.DependencyGraphEdge;
import org.apache.maven.archiva.dependency.graph.DependencyGraphNode;
import org.apache.maven.archiva.dependency.graph.GraphTaskException;
import org.apache.maven.archiva.dependency.graph.walk.BaseVisitor;
import org.apache.maven.archiva.dependency.graph.walk.DependencyGraphWalker;
import org.apache.maven.archiva.dependency.graph.walk.WalkDepthFirstSearch;
import org.apache.maven.archiva.model.ArtifactReference;
import org.apache.maven.archiva.model.DependencyScope;
import org.apache.maven.archiva.model.Keys;
import org.apache.maven.archiva.model.VersionedReference;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
import org.apache.maven.archiva.security.ArchivaXworkUser;
import org.apache.maven.archiva.security.UserRepositories;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.shared.dependency.tree.DependencyNode;
import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException;
import org.apache.maven.shared.dependency.tree.traversal.DependencyNodeVisitor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* DependencyTree
* DependencyTree
*
* @version $Id$
*
* @plexus.component role="org.apache.maven.archiva.web.tags.DependencyTree"
* @plexus.component role="org.apache.maven.archiva.web.tags.DependencyTree"
*/
public class DependencyTree
implements Initializable
{
private Logger log = LoggerFactory.getLogger( DependencyTree.class );
/**
* @plexus.requirement
* role="org.apache.maven.archiva.dependency.graph.DependencyGraphBuilder"
* role-hint="project-model"
* @plexus.requirement role-hint="maven2"
*/
private DependencyGraphBuilder graphBuilder;
private DependencyTreeBuilder dependencyTreeBuilder;

private DependencyGraphFactory graphFactory = new DependencyGraphFactory();
/**
* @plexus.requirement
*/
private UserRepositories userRepositories;

public class TreeEntry
public static class TreeEntry
{
private String pre = "";

private String post = "";

private ArtifactReference artifact;
private Artifact artifact;

public void setArtifact( ArtifactReference artifact )
public void setArtifact( Artifact artifact )
{
this.artifact = artifact;
}

public ArtifactReference getArtifact()
public Artifact getArtifact()
{
return artifact;
}
@@ -89,21 +80,11 @@ public class DependencyTree
return post;
}

public void setPost( String post )
{
this.post = post;
}

public String getPre()
{
return pre;
}

public void setPre( String pre )
{
this.pre = pre;
}

public void appendPre( String string )
{
this.pre += string;
@@ -115,59 +96,64 @@ public class DependencyTree
}
}

public List<TreeEntry> gatherTreeList( String groupId, String artifactId, String modelVersion, String nodevar,
PageContext pageContext ) throws ArchivaException
public List<TreeEntry> gatherTreeList( String groupId, String artifactId, String modelVersion )
throws ArchivaException
{
if ( StringUtils.isBlank( groupId ) )
{
String emsg = "Error generating dependency tree [" + Keys.toKey( groupId, artifactId, modelVersion )
+ "]: groupId is blank.";
String emsg = "Error generating dependency tree [" + Keys.toKey( groupId, artifactId, modelVersion ) +
"]: groupId is blank.";
log.error( emsg );
throw new ArchivaException( emsg );
}

if ( StringUtils.isBlank( artifactId ) )
{
String emsg = "Error generating dependency tree [" + Keys.toKey( groupId, artifactId, modelVersion )
+ "]: artifactId is blank.";
String emsg = "Error generating dependency tree [" + Keys.toKey( groupId, artifactId, modelVersion ) +
"]: artifactId is blank.";
log.error( emsg );
throw new ArchivaException( emsg );
}

if ( StringUtils.isBlank( modelVersion ) )
{
String emsg = "Error generating dependency tree [" + Keys.toKey( groupId, artifactId, modelVersion )
+ "]: version is blank.";
String emsg = "Error generating dependency tree [" + Keys.toKey( groupId, artifactId, modelVersion ) +
"]: version is blank.";
log.error( emsg );
throw new ArchivaException( emsg );
}

DependencyGraph graph = fetchGraph( groupId, artifactId, modelVersion );
// TODO Cache the results to disk, in XML format, in the same place as the artifact is located.

if ( graph == null )
TreeListVisitor visitor = new TreeListVisitor();
try
{
dependencyTreeBuilder.buildDependencyTree( userRepositories.getObservableRepositoryIds( getPrincipal() ),
groupId, artifactId, modelVersion, visitor );
}
catch ( DependencyTreeBuilderException e )
{
throw new ArchivaException( "Graph is unexpectedly null." );
throw new ArchivaException( "Unable to build dependency tree: " + e.getMessage(), e );
}

TreeListVisitor treeListVisitor = new TreeListVisitor();
DependencyGraphWalker walker = new WalkDepthFirstSearch();
walker.visit( graph, treeListVisitor );
return visitor.getList();
}

return treeListVisitor.getList();
private String getPrincipal()
{
return ArchivaXworkUser.getActivePrincipal( ActionContext.getContext().getSession() );
}

class TreeListVisitor
extends BaseVisitor
private static class TreeListVisitor
implements DependencyNodeVisitor
{
private List<TreeEntry> list;

private int walkDepth;
private TreeEntry currentEntry;

private int outputDepth;
boolean firstChild = true;

private Stack<TreeEntry> entryStack = new Stack<TreeEntry>();

private TreeEntry currentEntry;
private DependencyNode firstNode;

public TreeListVisitor()
{
@@ -179,86 +165,48 @@ public class DependencyTree
return this.list;
}

public void discoverGraph( DependencyGraph graph )
public boolean visit( DependencyNode node )
{
super.discoverGraph( graph );
this.list.clear();
this.entryStack.clear();
walkDepth = 0;
outputDepth = -1;
}
if ( firstNode == null )
{
firstNode = node;
}

public void discoverNode( DependencyGraphNode node )
{
super.discoverNode( node );
currentEntry = new TreeEntry();

while ( walkDepth > outputDepth )
if ( firstChild )
{
currentEntry.appendPre( "<ul>" );
outputDepth++;
}

currentEntry.appendPre( "<li>" );
currentEntry.setArtifact( node.getArtifact() );
currentEntry.appendPost( "</li>" );
this.list.add( currentEntry );
this.entryStack.push( currentEntry );
}

public void finishNode( DependencyGraphNode node )
{
super.finishNode( node );

while ( walkDepth < outputDepth )
if ( !node.getChildren().isEmpty() )
{
currentEntry.appendPost( "</ul>" );
outputDepth--;
firstChild = true;
}

this.entryStack.pop();
}

public void discoverEdge( DependencyGraphEdge edge )
{
super.discoverEdge( edge );
walkDepth++;
return true;
}

public void finishEdge( DependencyGraphEdge edge )
public boolean endVisit( DependencyNode node )
{
super.finishEdge( edge );
walkDepth--;
}
}

private DependencyGraph fetchGraph( String groupId, String artifactId, String modelVersion )
throws ArchivaException
{
// TODO Cache the results to disk, in XML format, in the same place as the artifact is located.
firstChild = false;

VersionedReference projectRef = new VersionedReference();
projectRef.setGroupId( groupId );
projectRef.setArtifactId( artifactId );
projectRef.setVersion( modelVersion );
if ( !node.getChildren().isEmpty() )
{
currentEntry.appendPost( "</ul>" );
}

try
{
DependencyGraph depGraph = graphFactory.getGraph( projectRef );
if ( node == firstNode )
{
currentEntry.appendPost( "</ul>" );
}

return depGraph;
}
catch ( GraphTaskException e )
{
String emsg = "Unable to generate graph for [" + Keys.toKey( projectRef ) + "] : " + e.getMessage();
log.warn( emsg, e );
throw new ArchivaException( emsg, e );
return true;
}
}

public void initialize()
throws InitializationException
{
this.graphFactory.setGraphBuilder( graphBuilder );
this.graphFactory.setDesiredScope( DependencyScope.TEST );
}
}

+ 3
- 3
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/DependencyTreeTag.java View File

@@ -83,7 +83,7 @@ public class DependencyTreeTag

if ( treeIterator.hasNext() )
{
currentTreeEntry = (TreeEntry) treeIterator.next();
currentTreeEntry = treeIterator.next();
out( currentTreeEntry.getPre() );
exposeVariables();
return EVAL_BODY_AGAIN;
@@ -132,7 +132,7 @@ public class DependencyTreeTag
out( "<div class=\"dependency-graph\">" );
try
{
this.tree = deptree.gatherTreeList( groupId, artifactId, modelVersion, nodevar, pageContext );
this.tree = deptree.gatherTreeList( groupId, artifactId, modelVersion );
if ( CollectionUtils.isEmpty( this.tree ) )
{
@@ -141,7 +141,7 @@ public class DependencyTreeTag
treeIterator = tree.iterator();
currentTreeEntry = (TreeEntry) treeIterator.next();
currentTreeEntry = treeIterator.next();
out( currentTreeEntry.getPre() );
exposeVariables();
}

+ 64
- 0
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/configuration/TestConfiguration.java View File

@@ -0,0 +1,64 @@
package org.apache.archiva.configuration;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.ConfigurationListener;
import org.apache.maven.archiva.configuration.IndeterminateConfigurationException;
import org.codehaus.plexus.registry.RegistryException;
import org.codehaus.plexus.registry.RegistryListener;

public class TestConfiguration
implements ArchivaConfiguration
{
private Configuration configuration;

public Configuration getConfiguration()
{
return configuration;
}

public void save( Configuration configuration )
throws RegistryException, IndeterminateConfigurationException
{
this.configuration = configuration;
}

public boolean isDefaulted()
{
return false;
}

public void addListener( ConfigurationListener listener )
{
throw new UnsupportedOperationException();
}

public void removeListener( ConfigurationListener listener )
{
throw new UnsupportedOperationException();
}

public void addChangeListener( RegistryListener listener )
{
throw new UnsupportedOperationException();
}
}

+ 131
- 0
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/tags/DependencyTreeTest.java View File

@@ -0,0 +1,131 @@
package org.apache.maven.archiva.web.tags;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import java.util.List;

import org.apache.archiva.metadata.model.ProjectVersionMetadata;
import org.apache.archiva.metadata.repository.MetadataResolver;
import org.apache.archiva.metadata.repository.memory.TestMetadataResolver;
import org.apache.maven.archiva.common.ArchivaException;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.codehaus.plexus.spring.PlexusInSpringTestCase;

public class DependencyTreeTest
extends PlexusInSpringTestCase
{
private DependencyTree tree;

private ArtifactFactory artifactFactory;

private static final String TEST_VERSION = "version";

private static final String TEST_REPO_ID = "test-repo";

private static final String TEST_GROUP_ID = "groupId";

private static final String TEST_ARTIFACT_ID = "artifactId";

@Override
protected void setUp()
throws Exception
{
super.setUp();

Configuration configuration = new Configuration();
ManagedRepositoryConfiguration repoConfig = new ManagedRepositoryConfiguration();
repoConfig.setId( TEST_REPO_ID );
repoConfig.setLocation( getTestPath( "src/test/repositories/test" ) );
configuration.addManagedRepository( repoConfig );

ArchivaConfiguration archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class );
archivaConfiguration.save( configuration );

tree = (DependencyTree) lookup( DependencyTree.class );

artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.class );

TestMetadataResolver metadataResolver = (TestMetadataResolver) lookup( MetadataResolver.class );
ProjectVersionMetadata metadata = new ProjectVersionMetadata();
metadata.setId( TEST_VERSION );
metadataResolver.setProjectVersion( TEST_REPO_ID, TEST_GROUP_ID, TEST_ARTIFACT_ID, metadata );
}

public void testTree()
throws ArchivaException
{
List<DependencyTree.TreeEntry> entries = tree.gatherTreeList( TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_VERSION );
assertEquals( 8, entries.size() );

DependencyTree.TreeEntry artifactId = entries.get( 0 );
assertEquals( "<ul><li>", artifactId.getPre() );
assertEquals( createPomArtifact( TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_VERSION ), artifactId.getArtifact() );
assertEquals( "</li>", artifactId.getPost() );

DependencyTree.TreeEntry child1 = entries.get( 1 );
assertEquals( "<ul><li>", child1.getPre() );
assertEquals( createArtifact( TEST_GROUP_ID, "child1", "1.0" ), child1.getArtifact() );
assertEquals( "</li>", child1.getPost() );

DependencyTree.TreeEntry grandchild = entries.get( 2 );
assertEquals( "<ul><li>", grandchild.getPre() );
assertEquals( createArtifact( TEST_GROUP_ID, "grandchild1", "2.0" ), grandchild.getArtifact() );
assertEquals( "</li>", grandchild.getPost() );

DependencyTree.TreeEntry greatGrandchild = entries.get( 3 );
assertEquals( "<ul><li>", greatGrandchild.getPre() );
assertEquals( createArtifact( TEST_GROUP_ID, "great-grandchild", "3.0" ), greatGrandchild.getArtifact() );
assertEquals( "</li></ul></ul>", greatGrandchild.getPost() );

DependencyTree.TreeEntry child2 = entries.get( 4 );
assertEquals( "<li>", child2.getPre() );
assertEquals( createArtifact( TEST_GROUP_ID, "child2", "1.0" ), child2.getArtifact() );
assertEquals( "</li>", child2.getPost() );

DependencyTree.TreeEntry grandchild2 = entries.get( 5 );
assertEquals( "<ul><li>", grandchild2.getPre() );
assertEquals( createArtifact( TEST_GROUP_ID, "grandchild2", "2.0" ), grandchild2.getArtifact() );
assertEquals( "</li>", grandchild2.getPost() );

DependencyTree.TreeEntry grandchild3 = entries.get( 6 );
assertEquals( "<li>", grandchild3.getPre() );
assertEquals( createArtifact( TEST_GROUP_ID, "grandchild3", "2.0" ), grandchild3.getArtifact() );
assertEquals( "</li></ul>", grandchild3.getPost() );

DependencyTree.TreeEntry child3 = entries.get( 7 );
assertEquals( "<li>", child3.getPre() );
assertEquals( createArtifact( TEST_GROUP_ID, "child3", "1.0" ), child3.getArtifact() );
assertEquals( "</li></ul></ul>", child3.getPost() );
}

private Artifact createPomArtifact( String groupId, String artifactId, String version )
{
return artifactFactory.createProjectArtifact( groupId, artifactId, version );
}

private Artifact createArtifact( String groupId, String artifactId, String version )
{
return artifactFactory.createBuildArtifact( groupId, artifactId, version, "jar" );
}
}

+ 43
- 0
archiva-modules/archiva-web/archiva-webapp/src/test/repositories/test/groupId/artifactId/version/artifactId-version.pom View File

@@ -0,0 +1,43 @@
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->

<project>
<modelVersion>4.0.0</modelVersion>
<groupId>groupId</groupId>
<artifactId>artifactId</artifactId>
<version>version</version>

<dependencies>
<dependency>
<groupId>groupId</groupId>
<artifactId>child1</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>groupId</groupId>
<artifactId>child2</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>groupId</groupId>
<artifactId>child3</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</project>

+ 33
- 0
archiva-modules/archiva-web/archiva-webapp/src/test/repositories/test/groupId/child1/1.0/child1-1.0.pom View File

@@ -0,0 +1,33 @@
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->

<project>
<modelVersion>4.0.0</modelVersion>
<groupId>groupId</groupId>
<artifactId>child1</artifactId>
<version>1.0</version>

<dependencies>
<dependency>
<groupId>groupId</groupId>
<artifactId>grandchild1</artifactId>
<version>2.0</version>
</dependency>
</dependencies>
</project>

+ 37
- 0
archiva-modules/archiva-web/archiva-webapp/src/test/repositories/test/groupId/child2/1.0/child2-1.0.pom View File

@@ -0,0 +1,37 @@
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->

<project>
<modelVersion>4.0.0</modelVersion>
<groupId>groupId</groupId>
<artifactId>child2</artifactId>
<version>1.0</version>
<dependencies>
<dependency>
<groupId>groupId</groupId>
<artifactId>grandchild2</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>groupId</groupId>
<artifactId>grandchild3</artifactId>
<version>2.0</version>
</dependency>
</dependencies>
</project>

+ 25
- 0
archiva-modules/archiva-web/archiva-webapp/src/test/repositories/test/groupId/child3/1.0/child3-1.0.pom View File

@@ -0,0 +1,25 @@
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->

<project>
<modelVersion>4.0.0</modelVersion>
<groupId>groupId</groupId>
<artifactId>child3</artifactId>
<version>1.0</version>
</project>

+ 32
- 0
archiva-modules/archiva-web/archiva-webapp/src/test/repositories/test/groupId/grandchild1/2.0/grandchild1-2.0.pom View File

@@ -0,0 +1,32 @@
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->

<project>
<modelVersion>4.0.0</modelVersion>
<groupId>groupId</groupId>
<artifactId>grandchild1</artifactId>
<version>2.0</version>
<dependencies>
<dependency>
<groupId>groupId</groupId>
<artifactId>great-grandchild</artifactId>
<version>3.0</version>
</dependency>
</dependencies>
</project>

+ 25
- 0
archiva-modules/archiva-web/archiva-webapp/src/test/repositories/test/groupId/grandchild2/2.0/grandchild2-2.0.pom View File

@@ -0,0 +1,25 @@
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->

<project>
<modelVersion>4.0.0</modelVersion>
<groupId>groupId</groupId>
<artifactId>grandchild2</artifactId>
<version>2.0</version>
</project>

+ 25
- 0
archiva-modules/archiva-web/archiva-webapp/src/test/repositories/test/groupId/grandchild3/2.0/grandchild3-2.0.pom View File

@@ -0,0 +1,25 @@
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->

<project>
<modelVersion>4.0.0</modelVersion>
<groupId>groupId</groupId>
<artifactId>grandchild2</artifactId>
<version>2.0</version>
</project>

+ 26
- 0
archiva-modules/archiva-web/archiva-webapp/src/test/repositories/test/groupId/great-grandchild/3.0/great-grandchild-3.0.pom View File

@@ -0,0 +1,26 @@
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->

<project>
<modelVersion>4.0.0</modelVersion>
<groupId>groupId</groupId>
<artifactId>great-grandchild</artifactId>
<version>3.0</version>
<packaging>pom</packaging>
</project>

+ 39
- 0
archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/tags/DependencyTreeTest.xml View File

@@ -0,0 +1,39 @@
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->

<plexus>
<components>
<component>
<role>org.apache.maven.archiva.security.UserRepositories</role>
<role-hint>default</role-hint>
<implementation>org.apache.maven.archiva.security.UserRepositoriesStub</implementation>
</component>
<component>
<role>org.apache.archiva.metadata.repository.MetadataResolver</role>
<role-hint>default</role-hint>
<implementation>org.apache.archiva.metadata.repository.memory.TestMetadataResolver</implementation>
<instantiation-strategy>per-lookup</instantiation-strategy>
</component>
<component>
<role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role>
<role-hint>default</role-hint>
<implementation>org.apache.archiva.configuration.TestConfiguration</implementation>
</component>
</components>
</plexus>

+ 15
- 0
archiva-modules/plugins/maven2-repository/pom.xml View File

@@ -55,6 +55,21 @@
<groupId>org.apache.maven</groupId>
<artifactId>maven-model-builder</artifactId>
</dependency>
<!-- TODO: remove when dependency-tree declares it explicitly, it is currently through the excluded maven-project -->
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-dependency-tree</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-configuration</artifactId>

+ 445
- 0
archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/DefaultDependencyTreeBuilder.java View File

@@ -0,0 +1,445 @@
package org.apache.archiva.dependency.tree.maven2;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.apache.archiva.metadata.repository.MetadataResolver;
import org.apache.archiva.metadata.repository.MetadataResolverException;
import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator;
import org.apache.archiva.metadata.repository.storage.maven2.RepositoryModelResolver;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
import org.apache.maven.artifact.metadata.ResolutionGroup;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactCollector;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.filter.AndArtifactFilter;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter;
import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.artifact.versioning.ManagedVersionMap;
import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.DependencyManagement;
import org.apache.maven.model.Exclusion;
import org.apache.maven.model.Model;
import org.apache.maven.model.building.DefaultModelBuildingRequest;
import org.apache.maven.model.building.ModelBuilder;
import org.apache.maven.model.building.ModelBuildingException;
import org.apache.maven.model.building.ModelBuildingRequest;
import org.apache.maven.model.resolution.UnresolvableModelException;
import org.apache.maven.shared.dependency.tree.DependencyNode;
import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException;
import org.apache.maven.shared.dependency.tree.DependencyTreeResolutionListener;
import org.apache.maven.shared.dependency.tree.filter.AncestorOrSelfDependencyNodeFilter;
import org.apache.maven.shared.dependency.tree.filter.DependencyNodeFilter;
import org.apache.maven.shared.dependency.tree.filter.StateDependencyNodeFilter;
import org.apache.maven.shared.dependency.tree.traversal.BuildingDependencyNodeVisitor;
import org.apache.maven.shared.dependency.tree.traversal.CollectingDependencyNodeVisitor;
import org.apache.maven.shared.dependency.tree.traversal.DependencyNodeVisitor;
import org.apache.maven.shared.dependency.tree.traversal.FilteringDependencyNodeVisitor;
import org.codehaus.plexus.logging.AbstractLogEnabled;

/**
* Default implementation of <code>DependencyTreeBuilder</code>. Customized wrapper for maven-dependency-tree to use
* maven-model-builder instead of maven-project. Note that the role must differ to avoid conflicting with the
* maven-shared implementation.
*
* @plexus.component role="org.apache.archiva.dependency.tree.maven2.DependencyTreeBuilder" role-hint="maven2"
*/
public class DefaultDependencyTreeBuilder
extends AbstractLogEnabled
implements DependencyTreeBuilder
{
/**
* @plexus.requirement
*/
private ArtifactFactory factory;

/**
* @plexus.requirement
*/
private ArtifactCollector collector;

/**
* @plexus.requirement
*/
private ModelBuilder builder;

/**
* @plexus.requirement
*/
private MetadataResolver metadataResolver;

/**
* @plexus.requirement role-hint="maven2"
*/
private RepositoryPathTranslator pathTranslator;

/**
* @plexus.requirement
*/
private ArchivaConfiguration archivaConfiguration;

public void buildDependencyTree( List<String> repositoryIds, String groupId, String artifactId, String version,
DependencyNodeVisitor nodeVisitor )
throws DependencyTreeBuilderException
{
DependencyTreeResolutionListener listener = new DependencyTreeResolutionListener( getLogger() );

Artifact projectArtifact = factory.createProjectArtifact( groupId, artifactId, version );
File basedir = findArtifactInRepositories( repositoryIds, projectArtifact );

if ( basedir == null )
{
// metadata could not be resolved
return;
}

try
{
Model model =
buildProject( new RepositoryModelResolver( basedir, pathTranslator ), groupId, artifactId, version );

Map managedVersions = createManagedVersionMap( model );

Set<Artifact> dependencyArtifacts = createArtifacts( model, null );

ArtifactMetadataSource metadataSource = new MetadataArtifactMetadataSource( repositoryIds );

// Note that we don't permit going to external repositories. We don't need to pass in a local and remote
// since our metadata source has control over them
collector.collect( dependencyArtifacts, projectArtifact, managedVersions, null, null, metadataSource, null,
Collections.singletonList( listener ) );

DependencyNode rootNode = listener.getRootNode();

// TODO: remove the need for this when the serializer can calculate last nodes from visitor calls only
DependencyNodeVisitor visitor = new BuildingDependencyNodeVisitor( nodeVisitor );

CollectingDependencyNodeVisitor collectingVisitor = new CollectingDependencyNodeVisitor();
DependencyNodeVisitor firstPassVisitor =
new FilteringDependencyNodeVisitor( collectingVisitor, StateDependencyNodeFilter.INCLUDED );
rootNode.accept( firstPassVisitor );

DependencyNodeFilter secondPassFilter =
new AncestorOrSelfDependencyNodeFilter( collectingVisitor.getNodes() );
visitor = new FilteringDependencyNodeVisitor( visitor, secondPassFilter );

rootNode.accept( visitor );
}
catch ( ArtifactResolutionException e )
{
throw new DependencyTreeBuilderException( "Cannot build project dependency tree " + e.getMessage(), e );
}
catch ( InvalidVersionSpecificationException e )
{
throw new DependencyTreeBuilderException( "Invalid dependency version for artifact " + projectArtifact );
}
catch ( ModelBuildingException e )
{
throw new DependencyTreeBuilderException( "Cannot build project dependency tree " + e.getMessage(), e );
}
catch ( UnresolvableModelException e )
{
throw new DependencyTreeBuilderException( "Cannot build project dependency tree " + e.getMessage(), e );
}
}

private File findArtifactInRepositories( List<String> repositoryIds, Artifact projectArtifact )
{
for ( String repoId : repositoryIds )
{
ManagedRepositoryConfiguration repositoryConfiguration =
archivaConfiguration.getConfiguration().findManagedRepositoryById( repoId );

File repoDir = new File( repositoryConfiguration.getLocation() );
File file = pathTranslator.toFile( repoDir, projectArtifact.getGroupId(), projectArtifact.getArtifactId(),
projectArtifact.getBaseVersion(),
projectArtifact.getArtifactId() + "-" + projectArtifact.getVersion() +
".pom" );

if ( file.exists() )
{
return repoDir;
}
}
return null;
}

private Model buildProject( RepositoryModelResolver modelResolver, String groupId, String artifactId,
String version )
throws ModelBuildingException, UnresolvableModelException
{
ModelBuildingRequest req = new DefaultModelBuildingRequest();
req.setProcessPlugins( false );
req.setModelSource( modelResolver.resolveModel( groupId, artifactId, version ) );
req.setModelResolver( modelResolver );
req.setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL );

return builder.build( req ).getEffectiveModel();
}

// from maven-project to avoid the dependency on it
private Set<Artifact> createArtifacts( Model model, ArtifactFilter dependencyFilter )
throws InvalidVersionSpecificationException
{
Collection<Dependency> dependencies = model.getDependencies();
Set<Artifact> projectArtifacts = new LinkedHashSet<Artifact>( dependencies.size() );

for ( Dependency dependency : dependencies )
{
String scope = dependency.getScope();

if ( StringUtils.isEmpty( scope ) )
{
scope = Artifact.SCOPE_COMPILE;

dependency.setScope( scope );
}

VersionRange versionRange = VersionRange.createFromVersionSpec( dependency.getVersion() );
Artifact artifact =
factory.createDependencyArtifact( dependency.getGroupId(), dependency.getArtifactId(), versionRange,
dependency.getType(), dependency.getClassifier(), scope, null,
dependency.isOptional() );

if ( Artifact.SCOPE_SYSTEM.equals( scope ) )
{
artifact.setFile( new File( dependency.getSystemPath() ) );
}

ArtifactFilter artifactFilter = dependencyFilter;

// MNG-3769: It would be nice to be able to process relocations here,
// so we could have this filtering step apply to post-relocated dependencies.
// HOWEVER, this would require a much more invasive POM resolution process
// in order to look for relocations, which would make the early steps in
// a Maven build way too heavy.
if ( artifact != null && ( artifactFilter == null || artifactFilter.include( artifact ) ) )
{
if ( dependency.getExclusions() != null && !dependency.getExclusions().isEmpty() )
{
List<String> exclusions = new ArrayList<String>();
for ( Object o : dependency.getExclusions() )
{
Exclusion e = (Exclusion) o;
exclusions.add( e.getGroupId() + ":" + e.getArtifactId() );
}

ArtifactFilter newFilter = new ExcludesArtifactFilter( exclusions );

if ( artifactFilter != null )
{
AndArtifactFilter filter = new AndArtifactFilter();
filter.add( artifactFilter );
filter.add( newFilter );
artifactFilter = filter;
}
else
{
artifactFilter = newFilter;
}
}

artifact.setDependencyFilter( artifactFilter );

projectArtifacts.add( artifact );
}
}

return projectArtifacts;

}

// from maven-project to avoid the dependency on it

private Map createManagedVersionMap( Model model )
throws InvalidVersionSpecificationException
{
DependencyManagement dependencyManagement = model.getDependencyManagement();

Map<String, Artifact> map = null;
List<Dependency> deps;
if ( ( dependencyManagement != null ) && ( ( deps = dependencyManagement.getDependencies() ) != null ) &&
( deps.size() > 0 ) )
{
map = new ManagedVersionMap( map );

for ( Dependency dependency : dependencyManagement.getDependencies() )
{

VersionRange versionRange = VersionRange.createFromVersionSpec( dependency.getVersion() );

Artifact artifact =
factory.createDependencyArtifact( dependency.getGroupId(), dependency.getArtifactId(), versionRange,
dependency.getType(), dependency.getClassifier(),
dependency.getScope(), dependency.isOptional() );
if ( getLogger().isDebugEnabled() )
{
getLogger().debug( " " + artifact );
}

// If the dependencyManagement section listed exclusions,
// add them to the managed artifacts here so that transitive
// dependencies will be excluded if necessary.
if ( ( null != dependency.getExclusions() ) && !dependency.getExclusions().isEmpty() )
{
List<String> exclusions = new ArrayList<String>();

for ( Exclusion exclusion : dependency.getExclusions() )
{
exclusions.add( exclusion.getGroupId() + ":" + exclusion.getArtifactId() );
}
ExcludesArtifactFilter eaf = new ExcludesArtifactFilter( exclusions );
artifact.setDependencyFilter( eaf );
}
else
{
artifact.setDependencyFilter( null );
}
map.put( dependency.getManagementKey(), artifact );
}
}
else
{
map = Collections.emptyMap();
}

return map;
}

private class MetadataArtifactMetadataSource
implements ArtifactMetadataSource
{
private final List<String> repositoryIds;

public MetadataArtifactMetadataSource( List<String> repositoryIds )
{
this.repositoryIds = repositoryIds;
}

// modified version from MavenMetadataSource to work with the simpler environment
public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository,
List remoteRepositories )
throws ArtifactMetadataRetrievalException
{
// TODO: we removed relocation support here. This is something that might need to be generically handled
// throughout this module

Artifact pomArtifact =
factory.createProjectArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(),
artifact.getScope() );

File basedir = findArtifactInRepositories( repositoryIds, pomArtifact );

Model project = null;
if ( !Artifact.SCOPE_SYSTEM.equals( artifact.getScope() ) && basedir != null )
{
try
{
project =
buildProject( new RepositoryModelResolver( basedir, pathTranslator ), artifact.getGroupId(),
artifact.getArtifactId(), artifact.getVersion() );
}
catch ( ModelBuildingException e )
{
throw new ArtifactMetadataRetrievalException( e.getMessage(), e, artifact );
}
catch ( UnresolvableModelException e )
{
throw new ArtifactMetadataRetrievalException( e.getMessage(), e, artifact );
}
}

ResolutionGroup result;

if ( project == null )
{
// TODO: we could record this so that it is displayed in the dependency tree as (...) or similar

// if the project is null, we encountered an invalid model (read: m1 POM)
// we'll just return an empty resolution group.
// or used the inherited scope (should that be passed to the buildFromRepository method above?)
result = new ResolutionGroup( pomArtifact, Collections.emptySet(), Collections.emptyList() );
}
else
{
Set artifacts = Collections.emptySet();
if ( !artifact.getArtifactHandler().isIncludesDependencies() )
{
try
{
artifacts = createArtifacts( project, artifact.getDependencyFilter() );
}
catch ( InvalidVersionSpecificationException e )
{
throw new ArtifactMetadataRetrievalException( e.getMessage(), e, artifact );
}
}

result = new ResolutionGroup( pomArtifact, artifacts, Collections.emptyList() );
}

return result;
}

public List retrieveAvailableVersions( Artifact artifact, ArtifactRepository localRepository,
List remoteRepositories )
throws ArtifactMetadataRetrievalException
{
try
{
Set<ArtifactVersion> versions = new HashSet<ArtifactVersion>();
for ( String repoId : repositoryIds )
{
Collection<String> projectVersions =
metadataResolver.getProjectVersions( repoId, artifact.getGroupId(), artifact.getArtifactId() );
for ( String version : projectVersions )
{
versions.add( new DefaultArtifactVersion( version ) );
}
}

return new ArrayList<ArtifactVersion>( versions );
}
catch ( MetadataResolverException e )
{
throw new ArtifactMetadataRetrievalException( e.getMessage(), e, artifact );
}
}
}
}

+ 47
- 0
archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/DependencyTreeBuilder.java View File

@@ -0,0 +1,47 @@
package org.apache.archiva.dependency.tree.maven2;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import java.util.List;

import org.apache.maven.artifact.factory.DefaultArtifactFactory;
import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException;
import org.apache.maven.shared.dependency.tree.traversal.DependencyNodeVisitor;

/**
* Builds a tree of dependencies for a given Maven project. Customized wrapper for maven-dependency-tree to use
* maven-model-builder instead of maven-project.
*/
public interface DependencyTreeBuilder
{
/**
* Builds a tree of dependencies for the specified Maven project.
*
* @param repositoryIds the list of repositories to search for metadata
* @param groupId the project groupId to build the tree for
* @param artifactId the project artifactId to build the tree for
* @param version the project version to build the tree for
* @param nodeVisitor visitor to apply to all nodes discovered
* @throws DependencyTreeBuilderException if the dependency tree cannot be resolved
*/
public void buildDependencyTree( List<String> repositoryIds, String groupId, String artifactId, String version,
DependencyNodeVisitor nodeVisitor )
throws DependencyTreeBuilderException;
}

+ 0
- 0
archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/dependency/tree/maven2/DependencyTreeBuilderTest.java View File


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save