mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-09 22:45:04 +00:00
Fix plugin properties generation to be exact about the file to copy to
the output zip
This commit is contained in:
parent
00a8b8799f
commit
fbf824f6a6
@ -120,12 +120,15 @@ public class PluginBuildPlugin extends BuildPlugin {
|
|||||||
// add the plugin properties and metadata to test resources, so unit tests can
|
// 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)
|
// know about the plugin (used by test security code to statically initialize the plugin in unit tests)
|
||||||
SourceSet testSourceSet = project.sourceSets.test
|
SourceSet testSourceSet = project.sourceSets.test
|
||||||
testSourceSet.output.dir(buildProperties.generatedResourcesDir, builtBy: 'pluginProperties')
|
testSourceSet.output.dir(buildProperties.descriptorOutput.parentFile, builtBy: 'pluginProperties')
|
||||||
testSourceSet.resources.srcDir(pluginMetadata)
|
testSourceSet.resources.srcDir(pluginMetadata)
|
||||||
|
|
||||||
// create the actual bundle task, which zips up all the files for the plugin
|
// 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]) {
|
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 pluginMetadata // metadata (eg custom security policy)
|
||||||
from project.jar // this plugin's jar
|
from project.jar // this plugin's jar
|
||||||
from project.configurations.runtime - project.configurations.provided // the dep jars
|
from project.configurations.runtime - project.configurations.provided // the dep jars
|
||||||
|
@ -22,6 +22,7 @@ import org.elasticsearch.gradle.VersionProperties
|
|||||||
import org.gradle.api.InvalidUserDataException
|
import org.gradle.api.InvalidUserDataException
|
||||||
import org.gradle.api.Task
|
import org.gradle.api.Task
|
||||||
import org.gradle.api.tasks.Copy
|
import org.gradle.api.tasks.Copy
|
||||||
|
import org.gradle.api.tasks.OutputFile
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a plugin descriptor.
|
* Creates a plugin descriptor.
|
||||||
@ -29,20 +30,20 @@ import org.gradle.api.tasks.Copy
|
|||||||
class PluginPropertiesTask extends Copy {
|
class PluginPropertiesTask extends Copy {
|
||||||
|
|
||||||
PluginPropertiesExtension extension
|
PluginPropertiesExtension extension
|
||||||
File generatedResourcesDir = new File(project.buildDir, 'generated-resources')
|
|
||||||
|
@OutputFile
|
||||||
|
File descriptorOutput = new File(project.buildDir, 'generated-resources/plugin-descriptor.properties')
|
||||||
|
|
||||||
PluginPropertiesTask() {
|
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') {
|
Task copyPluginPropertiesTemplate = project.tasks.create('copyPluginPropertiesTemplate') {
|
||||||
doLast {
|
doLast {
|
||||||
InputStream resourceTemplate = PluginPropertiesTask.getResourceAsStream('/plugin-descriptor.properties')
|
InputStream resourceTemplate = PluginPropertiesTask.getResourceAsStream("/${descriptorOutput.name}")
|
||||||
templateFile.parentFile.mkdirs()
|
templateFile.parentFile.mkdirs()
|
||||||
templateFile.setText(resourceTemplate.getText('UTF-8'), 'UTF-8')
|
templateFile.setText(resourceTemplate.getText('UTF-8'), 'UTF-8')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
doFirst {
|
|
||||||
project.delete(generatedResourcesDir)
|
|
||||||
}
|
|
||||||
dependsOn(copyPluginPropertiesTemplate)
|
dependsOn(copyPluginPropertiesTemplate)
|
||||||
extension = project.extensions.create('esplugin', PluginPropertiesExtension, project)
|
extension = project.extensions.create('esplugin', PluginPropertiesExtension, project)
|
||||||
project.afterEvaluate {
|
project.afterEvaluate {
|
||||||
@ -57,8 +58,8 @@ class PluginPropertiesTask extends Copy {
|
|||||||
throw new InvalidUserDataException('classname is a required setting for esplugin')
|
throw new InvalidUserDataException('classname is a required setting for esplugin')
|
||||||
}
|
}
|
||||||
// configure property substitution
|
// configure property substitution
|
||||||
from(templateFile)
|
from(templateFile.parentFile).include(descriptorOutput.name)
|
||||||
into(generatedResourcesDir)
|
into(descriptorOutput.parentFile)
|
||||||
Map<String, String> properties = generateSubstitutions()
|
Map<String, String> properties = generateSubstitutions()
|
||||||
expand(properties)
|
expand(properties)
|
||||||
inputs.properties(properties)
|
inputs.properties(properties)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user