|
|
|
@ -22,6 +22,8 @@ import org.gradle.api.file.ConfigurableFileCollection; |
|
|
|
import org.gradle.api.plugins.JavaPlugin; |
|
|
|
import org.gradle.api.plugins.JavaPlugin; |
|
|
|
import org.gradle.api.plugins.JavaPluginExtension; |
|
|
|
import org.gradle.api.plugins.JavaPluginExtension; |
|
|
|
import org.gradle.api.tasks.SourceSet; |
|
|
|
import org.gradle.api.tasks.SourceSet; |
|
|
|
|
|
|
|
import org.gradle.api.tasks.TaskProvider; |
|
|
|
|
|
|
|
import org.gradle.language.base.plugins.LifecycleBasePlugin; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* {@link Plugin} for projects that define test auto-configuration. When the |
|
|
|
* {@link Plugin} for projects that define test auto-configuration. When the |
|
|
|
@ -39,16 +41,20 @@ public class TestAutoConfigurationPlugin implements Plugin<Project> { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void apply(Project target) { |
|
|
|
public void apply(Project target) { |
|
|
|
target.getPlugins().withType(JavaPlugin.class, (plugin) -> { |
|
|
|
target.getPlugins().withType(JavaPlugin.class, (plugin) -> { |
|
|
|
target.getTasks().register("checkAutoConfigureImports", CheckAutoConfigureImports.class, (task) -> { |
|
|
|
TaskProvider<CheckAutoConfigureImports> checkAutoConfigureImports = target.getTasks() |
|
|
|
SourceSet mainSourceSet = target.getExtensions() |
|
|
|
.register("checkAutoConfigureImports", CheckAutoConfigureImports.class, (task) -> { |
|
|
|
.getByType(JavaPluginExtension.class) |
|
|
|
SourceSet mainSourceSet = target.getExtensions() |
|
|
|
.getSourceSets() |
|
|
|
.getByType(JavaPluginExtension.class) |
|
|
|
.getByName(SourceSet.MAIN_SOURCE_SET_NAME); |
|
|
|
.getSourceSets() |
|
|
|
task.setSource(mainSourceSet.getResources()); |
|
|
|
.getByName(SourceSet.MAIN_SOURCE_SET_NAME); |
|
|
|
ConfigurableFileCollection classpath = target.files(mainSourceSet.getRuntimeClasspath(), |
|
|
|
task.setSource(mainSourceSet.getResources()); |
|
|
|
target.getConfigurations().getByName(mainSourceSet.getRuntimeClasspathConfigurationName())); |
|
|
|
ConfigurableFileCollection classpath = target.files(mainSourceSet.getRuntimeClasspath(), |
|
|
|
task.setClasspath(classpath); |
|
|
|
target.getConfigurations().getByName(mainSourceSet.getRuntimeClasspathConfigurationName())); |
|
|
|
}); |
|
|
|
task.setClasspath(classpath); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
target.getTasks() |
|
|
|
|
|
|
|
.named(LifecycleBasePlugin.CHECK_TASK_NAME) |
|
|
|
|
|
|
|
.configure((check) -> check.dependsOn(checkAutoConfigureImports)); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|