1 | |
package org.apache.maven.archiva.dependency.graph.tasks; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
import org.apache.maven.archiva.dependency.graph.DependencyGraph; |
23 | |
import org.apache.maven.archiva.dependency.graph.DependencyGraphEdge; |
24 | |
import org.apache.maven.archiva.dependency.graph.walk.BaseVisitor; |
25 | |
import org.apache.maven.archiva.dependency.graph.walk.DependencyGraphVisitor; |
26 | |
import org.apache.maven.archiva.dependency.graph.walk.DependencyGraphWalker; |
27 | |
import org.apache.maven.archiva.model.ArtifactReference; |
28 | |
|
29 | |
import java.util.HashSet; |
30 | |
import java.util.Set; |
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
public class FlagCyclicEdgesVisitor |
38 | |
extends BaseVisitor |
39 | |
implements DependencyGraphVisitor |
40 | |
{ |
41 | |
private DependencyGraphWalker walker; |
42 | |
|
43 | 0 | private Set<DependencyGraphEdge> cyclicEdges = new HashSet<DependencyGraphEdge>(); |
44 | |
|
45 | |
public FlagCyclicEdgesVisitor( DependencyGraphWalker walker ) |
46 | 0 | { |
47 | 0 | this.walker = walker; |
48 | 0 | } |
49 | |
|
50 | |
public void discoverEdge( DependencyGraphEdge edge ) |
51 | |
{ |
52 | 0 | ArtifactReference artifact = edge.getNodeTo(); |
53 | |
|
54 | |
|
55 | 0 | if ( walker.getNodeVisitState( artifact ) == DependencyGraphWalker.PROCESSING ) |
56 | |
{ |
57 | 0 | edge.setDisabled( true ); |
58 | 0 | edge.setDisabledType( DependencyGraph.DISABLED_CYCLIC ); |
59 | 0 | edge.setDisabledReason( "Cycle detected" ); |
60 | |
|
61 | 0 | cyclicEdges.add( edge ); |
62 | |
} |
63 | 0 | } |
64 | |
|
65 | |
public Set<DependencyGraphEdge> getCyclicEdges() |
66 | |
{ |
67 | 0 | return cyclicEdges; |
68 | |
} |
69 | |
} |