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.DependencyGraphBuilder; |
24 | |
import org.apache.maven.archiva.dependency.graph.DependencyGraphUtils; |
25 | |
import org.apache.maven.archiva.dependency.graph.GraphTask; |
26 | |
import org.apache.maven.archiva.dependency.graph.GraphTaskException; |
27 | |
import org.apache.maven.archiva.dependency.graph.walk.DependencyGraphWalker; |
28 | |
import org.apache.maven.archiva.dependency.graph.walk.WalkDepthFirstSearch; |
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | 0 | public class PopulateGraphMasterTask |
36 | |
implements GraphTask |
37 | |
{ |
38 | |
private DependencyGraphBuilder builder; |
39 | |
|
40 | 0 | private ResolveGraphTask resolveGraphTask = new ResolveGraphTask(); |
41 | |
|
42 | 0 | private DependencyManagementApplier depManApplier = new DependencyManagementApplier(); |
43 | |
|
44 | |
public void executeTask( DependencyGraph graph ) |
45 | |
throws GraphTaskException |
46 | |
{ |
47 | 0 | DependencyGraphWalker walker = new WalkDepthFirstSearch(); |
48 | |
|
49 | 0 | boolean done = false; |
50 | 0 | int maxiters = 5; |
51 | |
|
52 | 0 | while ( !done ) |
53 | |
{ |
54 | 0 | resolveGraphTask.executeTask( graph ); |
55 | 0 | walker.visit( graph, depManApplier ); |
56 | |
|
57 | 0 | if ( !depManApplier.hasCreatedNodes() || ( maxiters < 0 ) ) |
58 | |
{ |
59 | 0 | done = true; |
60 | 0 | break; |
61 | |
} |
62 | |
|
63 | 0 | maxiters--; |
64 | |
} |
65 | |
|
66 | 0 | DependencyGraphUtils.cleanupOrphanedNodes( graph ); |
67 | 0 | } |
68 | |
|
69 | |
public String getTaskId() |
70 | |
{ |
71 | 0 | return "populate-graph"; |
72 | |
} |
73 | |
|
74 | |
public DependencyGraphBuilder getBuilder() |
75 | |
{ |
76 | 0 | return builder; |
77 | |
} |
78 | |
|
79 | |
public void setBuilder( DependencyGraphBuilder builder ) |
80 | |
{ |
81 | 0 | this.builder = builder; |
82 | 0 | this.resolveGraphTask.setBuilder( builder ); |
83 | 0 | this.depManApplier.setBuilder( builder ); |
84 | 0 | } |
85 | |
|
86 | |
} |