diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/PrecommitTasks.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/PrecommitTasks.groovy index c0573b4a74358..7e0d466c859e7 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/PrecommitTasks.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/PrecommitTasks.groovy @@ -65,10 +65,6 @@ class PrecommitTasks { precommitTasks.add(configureLoggerUsage(project)) } - if (project.path.startsWith(":x-pack:plugin:")) { - precommitTasks.add(configureFeatureAware(project)) - } - Map precommitOptions = [ name: 'precommit', group: JavaBasePlugin.VERIFICATION_GROUP, @@ -180,23 +176,4 @@ class PrecommitTasks { return loggerUsageTask } - private static Task configureFeatureAware(final Project project) { - final Task featureAwareTask = project.tasks.create('featureAwareCheck', FeatureAwareTask.class) - - // see the root Gradle file for additional logic regarding this configuration - project.configurations.create('featureAwarePlugin') - project.dependencies.add( - 'featureAwarePlugin', - "org.elasticsearch.xpack.test:feature-aware:${org.elasticsearch.gradle.VersionProperties.elasticsearch}") - project.dependencies.add( - 'featureAwarePlugin', - project.sourceSets.main.output.getClassesDirs()) - - featureAwareTask.configure { FeatureAwareTask fat -> - fat.classpath = project.configurations.featureAwarePlugin - } - - return featureAwareTask - } - } diff --git a/x-pack/plugin/build.gradle b/x-pack/plugin/build.gradle index 4a0b29c42582a..0eb7e3b1c0edc 100644 --- a/x-pack/plugin/build.gradle +++ b/x-pack/plugin/build.gradle @@ -1,12 +1,8 @@ import org.elasticsearch.gradle.LoggedExec -import org.elasticsearch.gradle.MavenFilteringHack +import org.elasticsearch.gradle.precommit.FeatureAwareTask import org.elasticsearch.gradle.test.NodeInfo import java.nio.charset.StandardCharsets -import java.nio.file.Files -import java.nio.file.Path -import java.nio.file.StandardCopyOption -import org.elasticsearch.gradle.test.RunTask; apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' @@ -17,6 +13,26 @@ dependencies { testCompile project(path: xpackModule('core'), configuration: 'testArtifacts') } +subprojects { + final SourceSet main = project.sourceSets.findByName("main") + if (main != null) { + final FeatureAwareTask featureAwareTask = project.tasks.create('featureAwareCheck', FeatureAwareTask.class) + + // see the root Gradle file for additional logic regarding this configuration + project.configurations.create('featureAwarePlugin') + project.dependencies.add( + 'featureAwarePlugin', + "org.elasticsearch.xpack.test:feature-aware:${org.elasticsearch.gradle.VersionProperties.elasticsearch}") + project.dependencies.add('featureAwarePlugin', main.output.getClassesDirs()) + + featureAwareTask.configure { FeatureAwareTask fat -> + fat.classpath = project.configurations.featureAwarePlugin + } + + project.precommit.dependsOn featureAwareTask + } +} + // https://github.com/elastic/x-plugins/issues/724 configurations { testArtifacts.extendsFrom testRuntime