1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.repository.metadata;
20
21 import org.apache.maven.artifact.ArtifactScopeEnum;
22 import org.codehaus.plexus.PlexusContainer;
23 import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
24
25
26
27
28
29
30 @Deprecated
31 public class MetadataResolutionResult {
32 MetadataTreeNode treeRoot;
33
34
35
36
37
38 ClasspathTransformation classpathTransformation;
39
40 GraphConflictResolver conflictResolver;
41
42
43 public MetadataResolutionResult() {}
44
45 public MetadataResolutionResult(MetadataTreeNode root) {
46 this.treeRoot = root;
47 }
48
49 public MetadataTreeNode getTree() {
50 return treeRoot;
51 }
52
53 public void setTree(MetadataTreeNode root) {
54 this.treeRoot = root;
55 }
56
57 public void initTreeProcessing(PlexusContainer plexus) throws ComponentLookupException {
58 classpathTransformation = plexus.lookup(ClasspathTransformation.class);
59 conflictResolver = plexus.lookup(GraphConflictResolver.class);
60 }
61
62 public MetadataGraph getGraph() throws MetadataResolutionException {
63 return treeRoot == null ? null : new MetadataGraph(treeRoot);
64 }
65
66 public MetadataGraph getGraph(ArtifactScopeEnum scope)
67 throws MetadataResolutionException, GraphConflictResolutionException {
68 if (treeRoot == null) {
69 return null;
70 }
71
72 if (conflictResolver == null) {
73 return null;
74 }
75
76 return conflictResolver.resolveConflicts(getGraph(), scope);
77 }
78
79 public MetadataGraph getGraph(MetadataResolutionRequestTypeEnum requestType)
80 throws MetadataResolutionException, GraphConflictResolutionException {
81 if (requestType == null) {
82 return null;
83 }
84
85 if (treeRoot == null) {
86 return null;
87 }
88
89 if (conflictResolver == null) {
90 return null;
91 }
92
93 if (requestType.equals(MetadataResolutionRequestTypeEnum.classpathCompile)) {
94 return conflictResolver.resolveConflicts(getGraph(), ArtifactScopeEnum.compile);
95 } else if (requestType.equals(MetadataResolutionRequestTypeEnum.classpathRuntime)) {
96 return conflictResolver.resolveConflicts(getGraph(), ArtifactScopeEnum.runtime);
97 } else if (requestType.equals(MetadataResolutionRequestTypeEnum.classpathTest)) {
98 return conflictResolver.resolveConflicts(getGraph(), ArtifactScopeEnum.test);
99 } else if (requestType.equals(MetadataResolutionRequestTypeEnum.graph)) {
100 return getGraph();
101 } else if (requestType.equals(MetadataResolutionRequestTypeEnum.versionedGraph)) {
102 return new MetadataGraph(getTree(), true, false);
103 } else if (requestType.equals(MetadataResolutionRequestTypeEnum.scopedGraph)) {
104 return new MetadataGraph(getTree(), true, true);
105 }
106 return null;
107 }
108
109 public ClasspathContainer getClasspath(ArtifactScopeEnum scope)
110 throws MetadataGraphTransformationException, MetadataResolutionException {
111 if (classpathTransformation == null) {
112 return null;
113 }
114
115 MetadataGraph dirtyGraph = getGraph();
116 if (dirtyGraph == null) {
117 return null;
118 }
119
120 return classpathTransformation.transform(dirtyGraph, scope, false);
121 }
122
123
124 public MetadataTreeNode getClasspathTree(ArtifactScopeEnum scope)
125 throws MetadataGraphTransformationException, MetadataResolutionException {
126 ClasspathContainer cpc = getClasspath(scope);
127 if (cpc == null) {
128 return null;
129 }
130
131 return cpc.getClasspathAsTree();
132 }
133
134
135 }