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 b047bc89da2..e955d5d507c 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginBuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginBuildPlugin.groovy @@ -120,12 +120,15 @@ public class PluginBuildPlugin extends BuildPlugin { // add the plugin properties and metadata to test resources, so unit tests can // know about the plugin (used by test security code to statically initialize the plugin in unit tests) SourceSet testSourceSet = project.sourceSets.test - testSourceSet.output.dir(buildProperties.generatedResourcesDir, builtBy: 'pluginProperties') + testSourceSet.output.dir(buildProperties.descriptorOutput.parentFile, builtBy: 'pluginProperties') testSourceSet.resources.srcDir(pluginMetadata) // create the actual bundle task, which zips up all the files for the plugin Zip bundle = project.tasks.create(name: 'bundlePlugin', type: Zip, dependsOn: [project.jar, buildProperties]) { - from buildProperties // plugin properties file + from(buildProperties.descriptorOutput.parentFile) { + // plugin properties file + include(buildProperties.descriptorOutput.name) + } from pluginMetadata // metadata (eg custom security policy) from project.jar // this plugin's jar from project.configurations.runtime - project.configurations.provided // the dep jars 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 b7b2a7f1cb9..94bc0ba3e75 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginPropertiesTask.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginPropertiesTask.groovy @@ -22,6 +22,7 @@ import org.elasticsearch.gradle.VersionProperties import org.gradle.api.InvalidUserDataException import org.gradle.api.Task import org.gradle.api.tasks.Copy +import org.gradle.api.tasks.OutputFile /** * Creates a plugin descriptor. @@ -29,20 +30,20 @@ import org.gradle.api.tasks.Copy class PluginPropertiesTask extends Copy { PluginPropertiesExtension extension - File generatedResourcesDir = new File(project.buildDir, 'generated-resources') + + @OutputFile + File descriptorOutput = new File(project.buildDir, 'generated-resources/plugin-descriptor.properties') PluginPropertiesTask() { - File templateFile = new File(project.buildDir, 'templates/plugin-descriptor.properties') + File templateFile = new File(project.buildDir, "templates/${descriptorOutput.name}") Task copyPluginPropertiesTemplate = project.tasks.create('copyPluginPropertiesTemplate') { doLast { - InputStream resourceTemplate = PluginPropertiesTask.getResourceAsStream('/plugin-descriptor.properties') + InputStream resourceTemplate = PluginPropertiesTask.getResourceAsStream("/${descriptorOutput.name}") templateFile.parentFile.mkdirs() templateFile.setText(resourceTemplate.getText('UTF-8'), 'UTF-8') } } - doFirst { - project.delete(generatedResourcesDir) - } + dependsOn(copyPluginPropertiesTemplate) extension = project.extensions.create('esplugin', PluginPropertiesExtension, project) project.afterEvaluate { @@ -57,8 +58,8 @@ class PluginPropertiesTask extends Copy { throw new InvalidUserDataException('classname is a required setting for esplugin') } // configure property substitution - from(templateFile) - into(generatedResourcesDir) + from(templateFile.parentFile).include(descriptorOutput.name) + into(descriptorOutput.parentFile) Map properties = generateSubstitutions() expand(properties) inputs.properties(properties)