-
Notifications
You must be signed in to change notification settings - Fork 4.6k
/
DependencyCollector.java
260 lines (234 loc) · 8 KB
/
DependencyCollector.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
/*
* Copyright 2022 the original author or authors.
*
* Licensed 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.
*/
package org.gradle.api.artifacts.dsl;
import org.gradle.api.Action;
import org.gradle.api.Incubating;
import org.gradle.api.NonExtensible;
import org.gradle.api.artifacts.Dependency;
import org.gradle.api.artifacts.DependencyConstraint;
import org.gradle.api.artifacts.ExternalModuleDependency;
import org.gradle.api.artifacts.FileCollectionDependency;
import org.gradle.api.artifacts.MinimalExternalModuleDependency;
import org.gradle.api.file.FileCollection;
import org.gradle.api.provider.Provider;
import org.gradle.api.provider.ProviderConvertible;
import java.util.Set;
/**
* A {@code DependencyCollector} is used as part of a dependencies block in the DSL. A collector implements
* a single dependency scope and exposes the declared dependencies on {@link #getDependencies()}.
*
* @apiNote
* Gradle has specific extensions to make explicit calls to {@code add(...)} unnecessary from the DSL.
* <ul>
* <li>For Groovy DSL, we create {@code call(...)} equivalents for all the {@code add(...)} methods.</li>
* <li>For Kotlin DSL, we create {@code invoke(...)} equivalents for all the {@code add(...)} methods.</li>
* </ul>
*
* @implSpec This interface should not be implemented by end users or plugins.
* @implNote
* Changes to this interface may require changes to the
* {@link org.gradle.api.internal.artifacts.dsl.dependencies.DependenciesExtensionModule extension module for Groovy DSL} or
* {@link org.gradle.kotlin.dsl.DependenciesExtensions extension functions for Kotlin DSL}.
*
* @since 8.6
*/
@Incubating
@NonExtensible
@SuppressWarnings("JavadocReference")
public interface DependencyCollector {
/**
* Add a dependency.
*
* @param dependencyNotation dependency to add
* @see DependencyFactory#create(CharSequence) Valid dependency notation for this method
*
* @since 8.6
*/
void add(CharSequence dependencyNotation);
/**
* Add a dependency and configure it.
*
* @param dependencyNotation dependency to add
* @param configuration an action to configure the dependency
* @see DependencyFactory#create(CharSequence) Valid dependency notation for this method
*
* @since 8.6
*/
void add(CharSequence dependencyNotation, Action<? super ExternalModuleDependency> configuration);
/**
* Add a dependency.
*
* @param files files to add as a dependency
* @see DependencyFactory#create(FileCollection)
*
* @since 8.6
*/
void add(FileCollection files);
/**
* Add a dependency and configure it.
*
* @param files files to add as a dependency
* @param configuration an action to configure the dependency
* @see DependencyFactory#create(FileCollection)
*
* @since 8.6
*/
void add(FileCollection files, Action<? super FileCollectionDependency> configuration);
/**
* Add a dependency.
*
* @param externalModule external module to add as a dependency
*
* @since 8.6
*/
void add(ProviderConvertible<? extends MinimalExternalModuleDependency> externalModule);
/**
* Add a dependency and configure it.
*
* @param externalModule external module to add as a dependency
* @param configuration an action to configure the dependency
*
* @since 8.6
*/
void add(ProviderConvertible<? extends MinimalExternalModuleDependency> externalModule, Action<? super ExternalModuleDependency> configuration);
/**
* Add a dependency.
*
* @param dependency dependency to add
*
* @since 8.6
*/
void add(Dependency dependency);
/**
* Add a dependency and configure it.
*
* @param dependency dependency to add
* @param configuration an action to configure the dependency
*
* @since 8.6
*/
<D extends Dependency> void add(D dependency, Action<? super D> configuration);
/**
* Add a dependency.
*
* @param dependency dependency to add
*
* @since 8.6
*/
void add(Provider<? extends Dependency> dependency);
/**
* Add a dependency and configure it.
*
* @param dependency dependency to add
* @param configuration an action to configure the dependency
*
* @since 8.6
*/
<D extends Dependency> void add(Provider<? extends D> dependency, Action<? super D> configuration);
/**
* Add a dependency constraint.
*
* @param dependencyConstraint dependency constraint to add
* @since 8.7
*/
void addConstraint(DependencyConstraint dependencyConstraint);
/**
* Add a dependency constraint and configure it.
*
* @param dependencyConstraint dependency constraint to add
* @param configuration an action to configure the dependency constraint
* @since 8.7
*/
void addConstraint(DependencyConstraint dependencyConstraint, Action<? super DependencyConstraint> configuration);
/**
* Add a dependency constraint, using a {@link Provider} to lazily create the constraint.
*
* @param dependencyConstraint dependency constraint to add
* @since 8.7
*/
void addConstraint(Provider<? extends DependencyConstraint> dependencyConstraint);
/**
* Add a dependency constraint and configure it, using a {@link Provider} to lazily create the constraint.
*
* @param dependencyConstraint dependency constraint to add
* @param configuration an action to configure the dependency constraint
* @since 8.7
*/
void addConstraint(Provider<? extends DependencyConstraint> dependencyConstraint, Action<? super DependencyConstraint> configuration);
/**
* Add a bundle.
*
* @param bundle the bundle to add
*
* @since 8.6
*/
<D extends Dependency> void bundle(Iterable<? extends D> bundle);
/**
* Add a bundle and configure them.
*
* @param bundle the bundle to add
* @param configuration an action to configure each dependency in the bundle
*
* @since 8.6
*/
<D extends Dependency> void bundle(Iterable<? extends D> bundle, Action<? super D> configuration);
/**
* Add a bundle.
*
* @param bundle the bundle to add
*
* @since 8.6
*/
<D extends Dependency> void bundle(Provider<? extends Iterable<? extends D>> bundle);
/**
* Add a bundle and configure them.
*
* @param bundle the bundle to add
* @param configuration an action to configure each dependency in the bundle
*
* @since 8.6
*/
<D extends Dependency> void bundle(Provider<? extends Iterable<? extends D>> bundle, Action<? super D> configuration);
/**
* Add a bundle.
*
* @param bundle the bundle to add
*
* @since 8.6
*/
<D extends Dependency> void bundle(ProviderConvertible<? extends Iterable<? extends D>> bundle);
/**
* Add a bundle and configure them.
*
* @param bundle the bundle to add
* @param configuration an action to configure each dependency in the bundle
*
* @since 8.6
*/
<D extends Dependency> void bundle(ProviderConvertible<? extends Iterable<? extends D>> bundle, Action<? super D> configuration);
/**
* Returns all dependencies declared on this collector.
*
* @since 8.6
*/
Provider<Set<Dependency>> getDependencies();
/**
* Returns all dependency constraints declared on this collector.
*
* @since 8.7
*/
Provider<Set<DependencyConstraint>> getDependencyConstraints();
}