forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:elastic/elasticsearch into zendisco2
- Loading branch information
Showing
76 changed files
with
2,009 additions
and
1,183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/MetaPluginBuildPlugin.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.gradle.plugin | ||
|
||
import org.elasticsearch.gradle.test.RestIntegTestTask | ||
import org.elasticsearch.gradle.test.RestTestPlugin | ||
import org.elasticsearch.gradle.test.RunTask | ||
import org.elasticsearch.gradle.test.StandaloneRestTestPlugin | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.api.file.FileCopyDetails | ||
import org.gradle.api.file.RelativePath | ||
import org.gradle.api.tasks.bundling.Zip | ||
|
||
class MetaPluginBuildPlugin implements Plugin<Project> { | ||
|
||
@Override | ||
void apply(Project project) { | ||
project.plugins.apply(StandaloneRestTestPlugin) | ||
project.plugins.apply(RestTestPlugin) | ||
|
||
createBundleTask(project) | ||
|
||
project.integTestCluster { | ||
dependsOn(project.bundlePlugin) | ||
distribution = 'zip' | ||
setupCommand('installMetaPlugin', 'bin/elasticsearch-plugin', 'install', 'file:' + project.bundlePlugin.archivePath) | ||
} | ||
|
||
RunTask run = project.tasks.create('run', RunTask) | ||
run.dependsOn(project.bundlePlugin) | ||
run.clusterConfig.plugin(project.path) | ||
} | ||
|
||
private static void createBundleTask(Project project) { | ||
|
||
MetaPluginPropertiesTask buildProperties = project.tasks.create('pluginProperties', MetaPluginPropertiesTask.class) | ||
|
||
// create the actual bundle task, which zips up all the files for the plugin | ||
Zip bundle = project.tasks.create(name: 'bundlePlugin', type: Zip, dependsOn: [buildProperties]) { | ||
into('elasticsearch') { | ||
from(buildProperties.descriptorOutput.parentFile) { | ||
// plugin properties file | ||
include(buildProperties.descriptorOutput.name) | ||
} | ||
} | ||
// due to how the renames work for each bundled plugin, we must exclude empty dirs or every subdir | ||
// within bundled plugin zips will show up at the root as an empty dir | ||
includeEmptyDirs = false | ||
|
||
} | ||
project.assemble.dependsOn(bundle) | ||
|
||
// also make the zip available as a configuration (used when depending on this project) | ||
project.configurations.create('zip') | ||
project.artifacts.add('zip', bundle) | ||
|
||
// a super hacky way to inject code to run at the end of each of the bundled plugin's configuration | ||
// to add itself back to this meta plugin zip | ||
project.afterEvaluate { | ||
buildProperties.extension.plugins.each { String bundledPluginProjectName -> | ||
Project bundledPluginProject = project.project(bundledPluginProjectName) | ||
bundledPluginProject.afterEvaluate { | ||
bundle.configure { | ||
dependsOn bundledPluginProject.bundlePlugin | ||
from(project.zipTree(bundledPluginProject.bundlePlugin.outputs.files.singleFile)) { | ||
eachFile { FileCopyDetails details -> | ||
// paths in the individual plugins begin with elasticsearch, and we want to add in the | ||
// bundled plugin name between that and each filename | ||
details.relativePath = new RelativePath(true, 'elasticsearch', bundledPluginProjectName, | ||
details.relativePath.toString().replace('elasticsearch/', '')) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/MetaPluginPropertiesTask.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.gradle.plugin | ||
|
||
import org.gradle.api.InvalidUserDataException | ||
import org.gradle.api.Task | ||
import org.gradle.api.tasks.Copy | ||
import org.gradle.api.tasks.OutputFile | ||
|
||
class MetaPluginPropertiesTask extends Copy { | ||
|
||
MetaPluginPropertiesExtension extension | ||
|
||
@OutputFile | ||
File descriptorOutput = new File(project.buildDir, 'generated-resources/meta-plugin-descriptor.properties') | ||
|
||
MetaPluginPropertiesTask() { | ||
File templateFile = new File(project.buildDir, "templates/${descriptorOutput.name}") | ||
Task copyPluginPropertiesTemplate = project.tasks.create('copyPluginPropertiesTemplate') { | ||
doLast { | ||
InputStream resourceTemplate = PluginPropertiesTask.getResourceAsStream("/${descriptorOutput.name}") | ||
templateFile.parentFile.mkdirs() | ||
templateFile.setText(resourceTemplate.getText('UTF-8'), 'UTF-8') | ||
} | ||
} | ||
|
||
dependsOn(copyPluginPropertiesTemplate) | ||
extension = project.extensions.create('es_meta_plugin', MetaPluginPropertiesExtension, project) | ||
project.afterEvaluate { | ||
// check require properties are set | ||
if (extension.name == null) { | ||
throw new InvalidUserDataException('name is a required setting for es_meta_plugin') | ||
} | ||
if (extension.description == null) { | ||
throw new InvalidUserDataException('description is a required setting for es_meta_plugin') | ||
} | ||
// configure property substitution | ||
from(templateFile.parentFile).include(descriptorOutput.name) | ||
into(descriptorOutput.parentFile) | ||
Map<String, String> properties = generateSubstitutions() | ||
expand(properties) | ||
inputs.properties(properties) | ||
} | ||
} | ||
|
||
Map<String, String> generateSubstitutions() { | ||
return ['name': extension.name, | ||
'description': extension.description | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
buildSrc/src/main/resources/META-INF/gradle-plugins/elasticsearch.es-meta-plugin.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# | ||
# Licensed to Elasticsearch under one or more contributor | ||
# license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright | ||
# ownership. Elasticsearch licenses this file to you under | ||
# the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
# | ||
|
||
implementation-class=org.elasticsearch.gradle.plugin.MetaPluginBuildPlugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.