1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.api.services;
20
21 import java.util.List;
22
23 import org.apache.maven.api.Artifact;
24 import org.apache.maven.api.DependencyCoordinates;
25 import org.apache.maven.api.Node;
26 import org.apache.maven.api.PathScope;
27 import org.apache.maven.api.Project;
28 import org.apache.maven.api.Service;
29 import org.apache.maven.api.Session;
30 import org.apache.maven.api.annotations.Experimental;
31 import org.apache.maven.api.annotations.Nonnull;
32
33
34
35
36 @Experimental
37 public interface DependencyResolver extends Service {
38
39
40
41
42
43
44
45
46
47
48
49
50
51 @Nonnull
52 default DependencyResolverResult collect(@Nonnull Session session, @Nonnull DependencyCoordinates root) {
53 return collect(DependencyResolverRequest.build(session, DependencyResolverRequest.RequestType.COLLECT, root));
54 }
55
56
57
58
59
60
61
62
63
64
65
66
67
68 @Nonnull
69 default DependencyResolverResult collect(@Nonnull Session session, @Nonnull Project project) {
70 return collect(
71 DependencyResolverRequest.build(session, DependencyResolverRequest.RequestType.COLLECT, project));
72 }
73
74
75
76
77
78
79
80
81
82
83
84
85
86 @Nonnull
87 default DependencyResolverResult collect(@Nonnull Session session, @Nonnull Artifact artifact) {
88 return collect(
89 DependencyResolverRequest.build(session, DependencyResolverRequest.RequestType.COLLECT, artifact));
90 }
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106 @Nonnull
107 default DependencyResolverResult collect(@Nonnull DependencyResolverRequest request) {
108 if (request.getRequestType() != DependencyResolverRequest.RequestType.COLLECT) {
109 throw new IllegalArgumentException("requestType should be COLLECT when calling collect()");
110 }
111 return resolve(request);
112 }
113
114
115
116
117
118
119
120
121
122
123 List<Node> flatten(Session session, Node node, PathScope scope) throws DependencyResolverException;
124
125 @Nonnull
126 default DependencyResolverResult flatten(@Nonnull Session session, @Nonnull Project project) {
127 return flatten(
128 DependencyResolverRequest.build(session, DependencyResolverRequest.RequestType.FLATTEN, project));
129 }
130
131 @Nonnull
132 default DependencyResolverResult flatten(
133 @Nonnull Session session, @Nonnull Project project, @Nonnull PathScope scope) {
134 return flatten(DependencyResolverRequest.build(
135 session, DependencyResolverRequest.RequestType.FLATTEN, project, scope));
136 }
137
138 @Nonnull
139 default DependencyResolverResult flatten(@Nonnull DependencyResolverRequest request) {
140 if (request.getRequestType() != DependencyResolverRequest.RequestType.FLATTEN) {
141 throw new IllegalArgumentException("requestType should be FLATTEN when calling flatten()");
142 }
143 return resolve(request);
144 }
145
146 @Nonnull
147 default DependencyResolverResult resolve(@Nonnull Session session, @Nonnull Project project) {
148 return resolve(
149 DependencyResolverRequest.build(session, DependencyResolverRequest.RequestType.RESOLVE, project));
150 }
151
152 @Nonnull
153 default DependencyResolverResult resolve(
154 @Nonnull Session session, @Nonnull Project project, @Nonnull PathScope scope) {
155 return resolve(DependencyResolverRequest.build(
156 session, DependencyResolverRequest.RequestType.RESOLVE, project, scope));
157 }
158
159 @Nonnull
160 default DependencyResolverResult resolve(@Nonnull Session session, @Nonnull DependencyCoordinates dependency) {
161 return resolve(
162 DependencyResolverRequest.build(session, DependencyResolverRequest.RequestType.RESOLVE, dependency));
163 }
164
165 @Nonnull
166 default DependencyResolverResult resolve(
167 @Nonnull Session session, @Nonnull DependencyCoordinates dependency, @Nonnull PathScope scope) {
168 return resolve(DependencyResolverRequest.build(
169 session, DependencyResolverRequest.RequestType.RESOLVE, dependency, scope));
170 }
171
172 @Nonnull
173 default DependencyResolverResult resolve(
174 @Nonnull Session session, @Nonnull List<DependencyCoordinates> dependencies) {
175 return resolve(
176 DependencyResolverRequest.build(session, DependencyResolverRequest.RequestType.RESOLVE, dependencies));
177 }
178
179 @Nonnull
180 default DependencyResolverResult resolve(
181 @Nonnull Session session, @Nonnull List<DependencyCoordinates> dependencies, @Nonnull PathScope scope) {
182 return resolve(DependencyResolverRequest.build(
183 session, DependencyResolverRequest.RequestType.RESOLVE, dependencies, scope));
184 }
185
186
187
188
189
190
191
192
193
194
195
196
197
198 DependencyResolverResult resolve(DependencyResolverRequest request)
199 throws DependencyResolverException, ArtifactResolverException;
200 }