From 6cdf4f3f7282f8f4f7c59a146823067c9df3c60d Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Wed, 15 Feb 2017 11:23:12 -0800 Subject: [PATCH] Plugins: Include license and notice files in zip (#23191) This commit adds the elasticsearch LICENSE.txt to all plugins that released with elasticsearch, as well as a generated NOTICE.txt specific to the dependencies of each plugin. --- .../gradle/plugin/PluginBuildPlugin.groovy | 21 +++++++++++++++++++ .../plugin/PluginPropertiesExtension.groovy | 11 ++++++++++ plugins/build.gradle | 3 +++ 3 files changed, 35 insertions(+) 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 d5295519ad2..b047bc89da2 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginBuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginBuildPlugin.groovy @@ -19,6 +19,7 @@ package org.elasticsearch.gradle.plugin import org.elasticsearch.gradle.BuildPlugin +import org.elasticsearch.gradle.NoticeTask import org.elasticsearch.gradle.test.RestIntegTestTask import org.elasticsearch.gradle.test.RunTask import org.gradle.api.Project @@ -71,6 +72,7 @@ public class PluginBuildPlugin extends BuildPlugin { project.integTest.clusterConfig.plugin(project.path) project.tasks.run.clusterConfig.plugin(project.path) addZipPomGeneration(project) + addNoticeGeneration(project) } project.namingConventions { @@ -244,4 +246,23 @@ public class PluginBuildPlugin extends BuildPlugin { } } } + + protected void addNoticeGeneration(Project project) { + File licenseFile = project.pluginProperties.extension.licenseFile + if (licenseFile != null) { + project.bundlePlugin.into('/') { + from(licenseFile.parentFile) { + include(licenseFile.name) + } + } + } + File noticeFile = project.pluginProperties.extension.licenseFile + if (noticeFile != null) { + NoticeTask generateNotice = project.tasks.create('generateNotice', NoticeTask.class) + generateNotice.dependencies(project) + project.bundlePlugin.into('/') { + from(generateNotice) + } + } + } } diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginPropertiesExtension.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginPropertiesExtension.groovy index 55022666936..353b8127545 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginPropertiesExtension.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginPropertiesExtension.groovy @@ -43,6 +43,17 @@ class PluginPropertiesExtension { @Input boolean hasClientJar = false + /** A license file that should be included in the built plugin zip. */ + @Input + File licenseFile = null + + /** + * A notice file that should be included in the built plugin zip. This will be + * extended with notices from the {@code licenses/} directory. + */ + @Input + File noticeFile = null + PluginPropertiesExtension(Project project) { name = project.name version = project.version diff --git a/plugins/build.gradle b/plugins/build.gradle index 8866dfc8eef..27655abf534 100644 --- a/plugins/build.gradle +++ b/plugins/build.gradle @@ -26,5 +26,8 @@ configure(subprojects.findAll { it.parent.path == project.path }) { esplugin { // for local ES plugins, the name of the plugin is the same as the directory name project.name + + licenseFile rootProject.file('LICENSE.txt') + noticeFile rootProject.file('NOTICE.txt') } }