diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy index b91a3b6d9919a..e7031004c2f4a 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy @@ -71,9 +71,6 @@ class BuildPlugin implements Plugin { project.pluginManager.apply('elasticsearch.publish') project.pluginManager.apply(DependenciesInfoPlugin) - // apply global test task failure listener - project.rootProject.pluginManager.apply(TestFailureReportingPlugin) - project.getTasks().register("buildResources", ExportElasticsearchBuildResourcesTask) project.extensions.getByType(ExtraPropertiesExtension).set('versions', VersionProperties.versions) @@ -141,36 +138,6 @@ class BuildPlugin implements Plugin { } } - - private static class TestFailureReportingPlugin implements Plugin { - @Override - void apply(Project project) { - if (project != project.rootProject) { - throw new IllegalStateException("${this.class.getName()} can only be applied to the root project.") - } - - project.gradle.addListener(new TaskActionListener() { - @Override - void beforeActions(Task task) { - - } - - @Override - void afterActions(Task task) { - if (task instanceof Test) { - ErrorReportingTestListener listener = task.extensions.findByType(ErrorReportingTestListener) - if (listener != null && listener.getFailedTests().size() > 0) { - task.logger.lifecycle("\nTests with failures:") - listener.getFailedTests().each { - task.logger.lifecycle(" - ${it.getFullName()}") - } - } - } - } - }) - } - } - private static inFipsJvm(){ return Boolean.parseBoolean(System.getProperty("tests.fips.enabled")); } diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/ElasticsearchJavaPlugin.java b/buildSrc/src/main/java/org/elasticsearch/gradle/ElasticsearchJavaPlugin.java index c8c2fa5d1101f..d81d992c63fe9 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/ElasticsearchJavaPlugin.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/ElasticsearchJavaPlugin.java @@ -39,6 +39,7 @@ import org.gradle.api.artifacts.dsl.RepositoryHandler; import org.gradle.api.artifacts.repositories.IvyArtifactRepository; import org.gradle.api.artifacts.repositories.MavenArtifactRepository; +import org.gradle.api.execution.TaskActionListener; import org.gradle.api.file.FileCollection; import org.gradle.api.plugins.BasePlugin; import org.gradle.api.plugins.JavaPlugin; @@ -78,8 +79,11 @@ public class ElasticsearchJavaPlugin implements Plugin { public void apply(Project project) { // make sure the global build info plugin is applied to the root project project.getRootProject().getPluginManager().apply(GlobalBuildInfoPlugin.class); + // apply global test task failure listener + project.getRootProject().getPluginManager().apply(TestFailureReportingPlugin.class); project.getPluginManager().apply(JavaPlugin.class); + configureConfigurations(project); configureRepositories(project); configureCompile(project); @@ -545,4 +549,31 @@ private static void configureJavadoc(Project project) { .named(LifecycleBasePlugin.CHECK_TASK_NAME) .configure(t -> t.dependsOn(project.getTasks().withType(Javadoc.class))); } + + static class TestFailureReportingPlugin implements Plugin { + @Override + public void apply(Project project) { + if (project != project.getRootProject()) { + throw new IllegalStateException(this.getClass().getName() + " can only be applied to the root project."); + } + + project.getGradle().addListener(new TaskActionListener() { + @Override + public void beforeActions(Task task) {} + + @Override + public void afterActions(Task task) { + if (task instanceof Test) { + ErrorReportingTestListener listener = task.getExtensions().findByType(ErrorReportingTestListener.class); + if (listener != null && listener.getFailedTests().size() > 0) { + task.getLogger().lifecycle("\nTests with failures:"); + for (ErrorReportingTestListener.Descriptor failure : listener.getFailedTests()) { + task.getLogger().lifecycle(" - " + failure.getFullName()); + } + } + } + } + }); + } + } }