rgoldberg
(Ross Goldberg)
August 25, 2019, 2:13pm
1
I’ve noticed that, in a Gradle 5.6 project using the java
plugin, all SourceSets
are eagerly created, even if they are added via register
instead of via create
(i.e. they are registered for lazy creation instead of explicitly eagerly created).
This occurs because when the java
plugin is applied, pluginConvention.getSourceSets().all(…)
is called (see the code linked below).
Is this intentional? Or should all
be changed to configureEach
? If it should be changed, I’ll file an issue.
private void configureSourceSets(JavaPluginConvention pluginConvention, final BuildOutputCleanupRegistry buildOutputCleanupRegistry) {
Project project = pluginConvention.getProject();
SourceSet main = pluginConvention.getSourceSets().create(SourceSet.MAIN_SOURCE_SET_NAME);
SourceSet test = pluginConvention.getSourceSets().create(SourceSet.TEST_SOURCE_SET_NAME);
test.setCompileClasspath(project.getObjects().fileCollection().from(main.getOutput(), project.getConfigurations().getByName(TEST_COMPILE_CLASSPATH_CONFIGURATION_NAME)));
test.setRuntimeClasspath(project.getObjects().fileCollection().from(test.getOutput(), main.getOutput(), project.getConfigurations().getByName(TEST_RUNTIME_CLASSPATH_CONFIGURATION_NAME)));
// Register the project's source set output directories
pluginConvention.getSourceSets().all(new Action<SourceSet>() {
@Override
public void execute(SourceSet sourceSet) {
buildOutputCleanupRegistry.registerOutputs(sourceSet.getOutput());
}
});
}
private void configureJavaDoc(final JavaPluginConvention pluginConvention) {
Project project = pluginConvention.getProject();
project.getTasks().register(JAVADOC_TASK_NAME, Javadoc.class, new Action<Javadoc>() {
rgoldberg
(Ross Goldberg)
August 26, 2019, 11:32am
2
It seems that some work on the lazy APIs must be done before this can be switched:
NamedDomainObjectProvider<SourceSet> should be replaced everywhere with a new SourceSetProvider extends NamedDomainObjectProvider<SourceSet>, which should add all the SourceSet#get*[Task|Configuration]Name(…) methods.
This will allow builds...
a:feature
from:contributor