Skip to content

Commit

Permalink
Move all of task configuration to x-pack:plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
jasontedor committed Jun 5, 2018
1 parent a1c4bab commit e6d9997
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 105 deletions.

This file was deleted.

56 changes: 40 additions & 16 deletions x-pack/plugin/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import org.elasticsearch.gradle.LoggedExec
import org.elasticsearch.gradle.precommit.FeatureAwareTask
import org.elasticsearch.gradle.plugin.PluginBuildPlugin
import org.elasticsearch.gradle.test.NodeInfo

import java.nio.charset.StandardCharsets
Expand All @@ -14,22 +14,46 @@ dependencies {
}

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
}
afterEvaluate {
if (project.plugins.hasPlugin(PluginBuildPlugin)) {
// see the root Gradle file for additional logic regarding this configuration
project.configurations.create('featureAwarePlugin')
project.dependencies.add('featureAwarePlugin', project.configurations.runtime)
project.dependencies.add(
'featureAwarePlugin',
"org.elasticsearch.xpack.test:feature-aware:${org.elasticsearch.gradle.VersionProperties.elasticsearch}")
project.dependencies.add('featureAwarePlugin', project.sourceSets.main.output.getClassesDirs())

final Task featureAwareTask = project.tasks.create("featureAwareCheck", LoggedExec) {
description = "Runs FeatureAwareCheck on main classes."
dependsOn project.configurations.featureAwarePlugin

final File successMarker = new File(project.buildDir, 'markers/featureAware')
outputs.file(successMarker)

executable = new File(project.runtimeJavaHome, 'bin/java')

// default to main class files if such a source set exists
final List files = []
if (project.sourceSets.findByName("main")) {
files.add(project.sourceSets.main.output.classesDir)
dependsOn project.tasks.classes
}
// filter out non-existent classes directories from empty source sets
final FileCollection classDirectories = project.files(files).filter { it.exists() }

project.precommit.dependsOn featureAwareTask
doFirst {
args('-cp', project.configurations.featureAwarePlugin.asPath, 'org.elasticsearch.xpack.test.feature_aware.FeatureAwareCheck')
classDirectories.each { args it.getAbsolutePath() }
}
doLast {
successMarker.parentFile.mkdirs()
successMarker.setText("", 'UTF-8')
}
}

project.precommit.dependsOn featureAwareTask
}
}
}

Expand Down

0 comments on commit e6d9997

Please sign in to comment.