From 196334babe23e273ce7aaa8324e92e49ee4721f7 Mon Sep 17 00:00:00 2001 From: Costin Leau Date: Wed, 4 Jul 2018 13:48:25 +0300 Subject: [PATCH] Fix license header generation on Windows Updates the build.gradle to take into account the OS differences for Windows (in particular line separator and project naming) --- build.gradle | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index a6b7b4ec6fb63..9d9f85db47bbc 100644 --- a/build.gradle +++ b/build.gradle @@ -445,12 +445,19 @@ allprojects { } File licenseHeaderFile; - if (eclipse.project.name.startsWith(':x-pack')) { + String prefix = ':x-pack'; + + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + prefix = prefix.replace(':', '_') + } + if (eclipse.project.name.startsWith(prefix)) { 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') + + String lineSeparator = Os.isFamily(Os.FAMILY_WINDOWS) ? '\\\\r\\\\n' : '\\\\n' + String licenseHeader = licenseHeaderFile.getText('UTF-8').replace(System.lineSeparator(), lineSeparator) task copyEclipseSettings(type: Copy) { // TODO: "package this up" for external builds from new File(project.rootDir, 'buildSrc/src/main/resources/eclipse.settings')