From b7f8e5c1df5e3369c0cf2f2e47109a8fb2ab6f6b Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Mon, 2 Nov 2015 10:14:04 -0800 Subject: [PATCH] Build: Make idea/eclipse project generation build generated resources for plugins This adds a generated-resources dir that the plugin properties are generated into. This must be outside of the build dir, since intellij has build as "excluded". closes #14392 --- .gitignore | 1 + build.gradle | 2 +- .../elasticsearch/gradle/plugin/PluginBuildPlugin.groovy | 8 +++++--- .../gradle/plugin/PluginPropertiesTask.groovy | 6 +++++- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index cd5cdbd1839..31f2aa5fc66 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ work/ logs/ .DS_Store build/ +generated-resources/ **/.local* docs/html/ docs/build.log diff --git a/build.gradle b/build.gradle index 9adb3aeb0eb..b3e5e09e07a 100644 --- a/build.gradle +++ b/build.gradle @@ -153,7 +153,7 @@ allprojects { apply plugin: 'idea' } -if (hasProperty('projectsPrefix') == false) { +if (projectsPrefix.isEmpty()) { idea { project { languageLevel = sourceCompatibility diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginBuildPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginBuildPlugin.groovy index cf9a1ff7302..63dd6f2beae 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginBuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginBuildPlugin.groovy @@ -84,9 +84,11 @@ class PluginBuildPlugin extends BuildPlugin { static Task configureBundleTask(Project project) { PluginPropertiesTask buildProperties = project.tasks.create(name: 'pluginProperties', type: PluginPropertiesTask) File pluginMetadata = project.file("src/main/plugin-metadata") - project.processTestResources { - from buildProperties - from pluginMetadata + project.sourceSets.test { + output.dir(buildProperties.propertiesFile.parentFile, builtBy: 'pluginProperties') + resources { + srcDir pluginMetadata + } } Task bundle = project.tasks.create(name: 'bundlePlugin', type: Zip, dependsOn: [project.jar, buildProperties]) bundle.configure { diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginPropertiesTask.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginPropertiesTask.groovy index 202de784f15..6dc5e2178c3 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginPropertiesTask.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginPropertiesTask.groovy @@ -33,9 +33,13 @@ class PluginPropertiesTask extends DefaultTask { PluginPropertiesExtension extension Map properties = new HashMap<>() + File generatedResourcesDir = new File(project.projectDir, "generated-resources") PluginPropertiesTask() { extension = project.extensions.create('esplugin', PluginPropertiesExtension, project) + project.clean { + delete generatedResourcesDir + } project.afterEvaluate { if (extension.description == null) { throw new InvalidUserDataException('description is a required setting for esplugin') @@ -54,7 +58,7 @@ class PluginPropertiesTask extends DefaultTask { } @OutputFile - File propertiesFile = new File(project.buildDir, "plugin" + File.separator + "plugin-descriptor.properties") + File propertiesFile = new File(generatedResourcesDir, "plugin-descriptor.properties") void fillProperties() { // TODO: need to copy the templated plugin-descriptor with a dependent task, since copy requires a file (not uri)