-
Notifications
You must be signed in to change notification settings - Fork 4.6k
/
SourceSet.java
402 lines (359 loc) · 12.8 KB
/
SourceSet.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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
/*
* Copyright 2010 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.tasks;
import groovy.lang.Closure;
import groovy.lang.DelegatesTo;
import org.gradle.api.Action;
import org.gradle.api.file.FileCollection;
import org.gradle.api.file.SourceDirectorySet;
import org.gradle.api.plugins.ExtensionAware;
import javax.annotation.Nullable;
/**
* A {@code SourceSet} represents a logical group of Java source and resource files. They
* are covered in more detail in the
* <a href="https://docs.gradle.org/current/userguide/building_java_projects.html#sec:java_source_sets">user manual</a>.
* <p>
* The following example shows how you can configure the 'main' source set, which in this
* case involves excluding classes whose package begins 'some.unwanted.package' from
* compilation of the source files in the 'java' {@link SourceDirectorySet}:
*
* <pre class='autoTested'>
* plugins {
* id 'java'
* }
*
* sourceSets {
* main {
* java {
* exclude 'some/unwanted/package/**'
* }
* }
* }
* </pre>
*/
public interface SourceSet extends ExtensionAware {
/**
* The name of the main source set.
*/
String MAIN_SOURCE_SET_NAME = "main";
/**
* The name of the test source set.
*/
String TEST_SOURCE_SET_NAME = "test";
/**
* Returns the name of this source set.
*
* @return The name. Never returns null.
*/
String getName();
/**
* Returns the classpath used to compile this source.
*
* @return The classpath. Never returns null.
*/
FileCollection getCompileClasspath();
/**
* Sets the classpath used to compile this source.
*
* @param classpath The classpath. Should not be null.
*/
void setCompileClasspath(FileCollection classpath);
/**
* Returns the classpath used to load annotation processors when compiling this source set.
* This path is also used for annotation processor discovery. The classpath can be empty,
* which means use the compile classpath; if you want to disable annotation processing,
* then use {@code -proc:none} as a compiler argument.
*
* @return The annotation processor path. Never returns null.
* @since 4.6
*/
FileCollection getAnnotationProcessorPath();
/**
* Set the classpath to use to load annotation processors when compiling this source set.
* This path is also used for annotation processor discovery. The classpath can be empty,
* which means use the compile classpath; if you want to disable annotation processing,
* then use {@code -proc:none} as a compiler argument.
*
* @param annotationProcessorPath The annotation processor path. Should not be null.
* @since 4.6
*/
void setAnnotationProcessorPath(FileCollection annotationProcessorPath);
/**
* Returns the classpath used to execute this source.
*
* @return The classpath. Never returns null.
*/
FileCollection getRuntimeClasspath();
/**
* Sets the classpath used to execute this source.
*
* @param classpath The classpath. Should not be null.
*/
void setRuntimeClasspath(FileCollection classpath);
/**
* {@link SourceSetOutput} is a {@link FileCollection} of all output directories (compiled classes, processed resources, etc.)
* and it provides means to configure the default output dirs and register additional output dirs. See examples in {@link SourceSetOutput}
*
* @return The output dirs, as a {@link SourceSetOutput}.
*/
SourceSetOutput getOutput();
/**
* Registers a set of tasks which are responsible for compiling this source set into the classes directory. The
* paths are evaluated as per {@link org.gradle.api.Task#dependsOn(Object...)}.
*
* @param taskPaths The tasks which compile this source set.
* @return this
*/
SourceSet compiledBy(Object... taskPaths);
/**
* Returns the non-Java resources which are to be copied into the resources output directory.
*
* @return the resources. Never returns null.
*/
SourceDirectorySet getResources();
/**
* Configures the non-Java resources for this set.
*
* <p>The given closure is used to configure the {@link SourceDirectorySet} which contains the resources.
*
* @param configureClosure The closure to use to configure the resources.
* @return this
*/
@SuppressWarnings("rawtypes")
SourceSet resources(@Nullable @DelegatesTo(SourceDirectorySet.class) Closure configureClosure);
/**
* Configures the non-Java resources for this set.
*
* <p>The given action is used to configure the {@link SourceDirectorySet} which contains the resources.
*
* @param configureAction The action to use to configure the resources.
* @return this
*/
SourceSet resources(Action<? super SourceDirectorySet> configureAction);
/**
* Returns the Java source which is to be compiled by the Java compiler into the class output directory.
*
* @return the Java source. Never returns null.
*/
SourceDirectorySet getJava();
/**
* Configures the Java source for this set.
*
* <p>The given closure is used to configure the {@link SourceDirectorySet} which contains the Java source.
*
* @param configureClosure The closure to use to configure the Java source.
* @return this
*/
@SuppressWarnings("rawtypes")
SourceSet java(@Nullable @DelegatesTo(SourceDirectorySet.class) Closure configureClosure);
/**
* Configures the Java source for this set.
*
* <p>The given action is used to configure the {@link SourceDirectorySet} which contains the Java source.
*
* @param configureAction The action to use to configure the Java source.
* @return this
*/
SourceSet java(Action<? super SourceDirectorySet> configureAction);
/**
* All Java source files for this source set. This includes, for example, source which is directly compiled, and
* source which is indirectly compiled through joint compilation.
*
* @return the Java source. Never returns null.
*/
SourceDirectorySet getAllJava();
/**
* All source files for this source set.
*
* @return the source. Never returns null.
*/
SourceDirectorySet getAllSource();
/**
* Returns the name of the classes task for this source set.
*
* @return The task name. Never returns null.
*/
String getClassesTaskName();
/**
* Returns the name of the resource process task for this source set.
*
* @return The task name. Never returns null.
*/
String getProcessResourcesTaskName();
/**
* Returns the name of the compile Java task for this source set.
*
* @return The task name. Never returns null.
*/
String getCompileJavaTaskName();
/**
* Returns the name of a compile task for this source set.
*
* @param language The language to be compiled.
* @return The task name. Never returns null.
*/
String getCompileTaskName(String language);
/**
* Returns the name of the Javadoc task for this source set.
*
* @return The task name. Never returns null.
*
* @since 6.0
*/
String getJavadocTaskName();
/**
* Returns the name of the Jar task for this source set.
*
* @return The task name. Never returns null.
*/
String getJarTaskName();
/**
* Returns the name of the Javadoc Jar task for this source set.
*
* @return The task name. Never returns null.
*
* @since 6.0
*/
String getJavadocJarTaskName();
/**
* Returns the name of the Source Jar task for this source set.
*
* @return The task name. Never returns null.
*
* @since 6.0
*/
String getSourcesJarTaskName();
/**
* Returns the name of a task for this source set.
*
* @param verb The action, may be null.
* @param target The target, may be null
* @return The task name, generally of the form ${verb}${name}${noun}
*/
String getTaskName(@Nullable String verb, @Nullable String target);
/**
* Returns the name of the compile only configuration for this source set.
*
* @return The compile only configuration name
*
* @since 2.12
*/
String getCompileOnlyConfigurationName();
/**
* Returns the name of the 'compile only api' configuration for this source set.
*
* @return The 'compile only api' configuration name
*
* @since 6.7
*/
String getCompileOnlyApiConfigurationName();
/**
* Returns the name of the compile classpath configuration for this source set.
*
* @return The compile classpath configuration
*
* @since 2.12
*/
String getCompileClasspathConfigurationName();
/**
* Returns the name of the configuration containing annotation processors and their
* dependencies needed to compile this source set.
*
* @return the name of the annotation processor configuration.
* @since 4.6
*/
String getAnnotationProcessorConfigurationName();
/**
* Returns the name of the API configuration for this source set. The API configuration
* contains dependencies which are exported by this source set, and is not transitive
* by default. This configuration is not meant to be resolved and should only contain
* dependencies that are required when compiling against this component.
*
* @return The API configuration name
*
* @since 3.3
*/
String getApiConfigurationName();
/**
* Returns the name of the implementation configuration for this source set. The implementation
* configuration should contain dependencies which are specific to the implementation of the component
* (internal APIs).
*
* @return The configuration name
* @since 3.4
*/
String getImplementationConfigurationName();
/**
* Returns the name of the configuration that should be used when compiling against the API
* of this component. This configuration is meant to be consumed by other components when
* they need to compile against it.
*
* @return The API compile configuration name
*
* @since 3.3
*/
String getApiElementsConfigurationName();
/**
* Returns the name of the configuration that contains dependencies that are only required
* at runtime of the component. Dependencies found in this configuration are visible to
* the runtime classpath of the component, but not to consumers.
*
* @return the runtime only configuration name
* @since 3.4
*/
String getRuntimeOnlyConfigurationName();
/**
* Returns the name of the runtime classpath configuration of this component: the runtime
* classpath contains elements of the implementation, as well as runtime only elements.
*
* @return the name of the runtime classpath configuration
* @since 3.4
*/
String getRuntimeClasspathConfigurationName();
/**
* Returns the name of the configuration containing elements that are strictly required
* at runtime. Consumers of this configuration will get all the mandatory elements for
* this component to execute at runtime.
*
* @return the name of the runtime elements configuration.
* @since 3.4
*/
String getRuntimeElementsConfigurationName();
/**
* Returns the name of the configuration that represents the variant that carries the
* Javadoc for this source set in packaged form. Used to publish a variant with a '-javadoc' zip.
*
* @return the name of the javadoc elements configuration.
* @since 6.0
*/
String getJavadocElementsConfigurationName();
/**
* Returns the name of the configuration that represents the variant that carries the
* original source code in packaged form. Used to publish a variant with a '-sources' zip.
*
* @return the name of the sources elements configuration.
* @since 6.0
*/
String getSourcesElementsConfigurationName();
/**
* Determines if this source set is the main source set
*
* @since 6.7
*/
static boolean isMain(SourceSet sourceSet) {
return MAIN_SOURCE_SET_NAME.equals(sourceSet.getName());
}
}