From 09b918545ddbf172aa05c600531fb75ea440ea0e Mon Sep 17 00:00:00 2001 From: Colin Goodheart-Smithe Date: Thu, 3 May 2018 08:48:49 +0100 Subject: [PATCH] Adds Eclipse config for xpack licence headers (#30299) Uses a filter on the copy task for the eclipse settings files to replace the token @@LICENSE_HEADER_TEXT@@ with the correct licence header from the new buildSrc/src/main/resources/license-headers directory --- build.gradle | 10 ++++++++++ .../eclipse.settings/org.eclipse.jdt.ui.prefs | 2 +- .../license-headers/elastic-license-header.txt | 5 +++++ .../license-headers/oss-license-header.txt | 18 ++++++++++++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 buildSrc/src/main/resources/license-headers/elastic-license-header.txt create mode 100644 buildSrc/src/main/resources/license-headers/oss-license-header.txt diff --git a/build.gradle b/build.gradle index c538c0cb898..395e1f600c9 100644 --- a/build.gradle +++ b/build.gradle @@ -19,6 +19,7 @@ import org.apache.tools.ant.taskdefs.condition.Os +import org.apache.tools.ant.filters.ReplaceTokens import org.elasticsearch.gradle.BuildPlugin import org.elasticsearch.gradle.LoggedExec import org.elasticsearch.gradle.Version @@ -406,10 +407,19 @@ allprojects { } } } + + File licenseHeaderFile; + if (eclipse.project.name.startsWith(':x-pack')) { + licenseHeaderFile = new File(project.rootDir, 'buildSrc/src/main/resources/license-headers/elastic-license-header.txt') + } else { + licenseHeaderFile = new File(project.rootDir, 'buildSrc/src/main/resources/license-headers/oss-license-header.txt') + } + String licenseHeader = licenseHeaderFile.getText('UTF-8').replace('\n', '\\\\n') task copyEclipseSettings(type: Copy) { // TODO: "package this up" for external builds from new File(project.rootDir, 'buildSrc/src/main/resources/eclipse.settings') into '.settings' + filter{ it.replaceAll('@@LICENSE_HEADER_TEXT@@', licenseHeader)} } // otherwise .settings is not nuked entirely task wipeEclipseSettings(type: Delete) { diff --git a/buildSrc/src/main/resources/eclipse.settings/org.eclipse.jdt.ui.prefs b/buildSrc/src/main/resources/eclipse.settings/org.eclipse.jdt.ui.prefs index 391a8715868..827a41bf634 100644 --- a/buildSrc/src/main/resources/eclipse.settings/org.eclipse.jdt.ui.prefs +++ b/buildSrc/src/main/resources/eclipse.settings/org.eclipse.jdt.ui.prefs @@ -3,4 +3,4 @@ formatter_settings_version=12 # Intellij IDEA import order org.eclipse.jdt.ui.importorder=;com;org;java;javax;\#; # License header -org.eclipse.jdt.ui.text.custom_code_templates= +org.eclipse.jdt.ui.text.custom_code_templates= diff --git a/buildSrc/src/main/resources/license-headers/elastic-license-header.txt b/buildSrc/src/main/resources/license-headers/elastic-license-header.txt new file mode 100644 index 00000000000..30371a1ef54 --- /dev/null +++ b/buildSrc/src/main/resources/license-headers/elastic-license-header.txt @@ -0,0 +1,5 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ \ No newline at end of file diff --git a/buildSrc/src/main/resources/license-headers/oss-license-header.txt b/buildSrc/src/main/resources/license-headers/oss-license-header.txt new file mode 100644 index 00000000000..d85645a12ef --- /dev/null +++ b/buildSrc/src/main/resources/license-headers/oss-license-header.txt @@ -0,0 +1,18 @@ +/* + * 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. + */ \ No newline at end of file