|
36 | 36 | import org.gradle.api.artifacts.ModuleDependency; |
37 | 37 | import org.gradle.api.artifacts.ProjectDependency; |
38 | 38 | import org.gradle.api.artifacts.ResolutionStrategy; |
39 | | -import org.gradle.api.execution.TaskActionListener; |
40 | 39 | import org.gradle.api.file.FileCollection; |
41 | 40 | import org.gradle.api.plugins.BasePlugin; |
42 | 41 | import org.gradle.api.plugins.JavaLibraryPlugin; |
@@ -72,8 +71,6 @@ public class ElasticsearchJavaPlugin implements Plugin<Project> { |
72 | 71 | public void apply(Project project) { |
73 | 72 | // make sure the global build info plugin is applied to the root project |
74 | 73 | project.getRootProject().getPluginManager().apply(GlobalBuildInfoPlugin.class); |
75 | | - // apply global test task failure listener |
76 | | - project.getRootProject().getPluginManager().apply(TestFailureReportingPlugin.class); |
77 | 74 | // common repositories setup |
78 | 75 | project.getPluginManager().apply(RepositoriesSetupPlugin.class); |
79 | 76 | project.getPluginManager().apply(JavaLibraryPlugin.class); |
@@ -223,7 +220,7 @@ public static void configureTestTasks(Project project) { |
223 | 220 | project.getTasks().withType(Test.class).configureEach(test -> { |
224 | 221 | File testOutputDir = new File(test.getReports().getJunitXml().getDestination(), "output"); |
225 | 222 |
|
226 | | - ErrorReportingTestListener listener = new ErrorReportingTestListener(test.getTestLogging(), testOutputDir); |
| 223 | + ErrorReportingTestListener listener = new ErrorReportingTestListener(test.getTestLogging(), test.getLogger(), testOutputDir); |
227 | 224 | test.getExtensions().add("errorReportingTestListener", listener); |
228 | 225 | test.addTestOutputListener(listener); |
229 | 226 | test.addTestListener(listener); |
@@ -473,31 +470,4 @@ private static void configureJavadoc(Project project) { |
473 | 470 | // ensure javadoc task is run with 'check' |
474 | 471 | project.getTasks().named(LifecycleBasePlugin.CHECK_TASK_NAME).configure(t -> t.dependsOn(javadoc)); |
475 | 472 | } |
476 | | - |
477 | | - static class TestFailureReportingPlugin implements Plugin<Project> { |
478 | | - @Override |
479 | | - public void apply(Project project) { |
480 | | - if (project != project.getRootProject()) { |
481 | | - throw new IllegalStateException(this.getClass().getName() + " can only be applied to the root project."); |
482 | | - } |
483 | | - |
484 | | - project.getGradle().addListener(new TaskActionListener() { |
485 | | - @Override |
486 | | - public void beforeActions(Task task) {} |
487 | | - |
488 | | - @Override |
489 | | - public void afterActions(Task task) { |
490 | | - if (task instanceof Test) { |
491 | | - ErrorReportingTestListener listener = task.getExtensions().findByType(ErrorReportingTestListener.class); |
492 | | - if (listener != null && listener.getFailedTests().size() > 0) { |
493 | | - task.getLogger().lifecycle("\nTests with failures:"); |
494 | | - for (ErrorReportingTestListener.Descriptor failure : listener.getFailedTests()) { |
495 | | - task.getLogger().lifecycle(" - " + failure.getFullName()); |
496 | | - } |
497 | | - } |
498 | | - } |
499 | | - } |
500 | | - }); |
501 | | - } |
502 | | - } |
503 | 473 | } |
0 commit comments