Skip to content

Commit f40581c

Browse files
authored
Fix license header generation on Windows (elastic#31790)
Updates the build.gradle to take into account the OS differences for Windows (in particular line separator and project naming)
1 parent 6acb591 commit f40581c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

build.gradle

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,12 +445,19 @@ allprojects {
445445
}
446446

447447
File licenseHeaderFile;
448-
if (eclipse.project.name.startsWith(':x-pack')) {
448+
String prefix = ':x-pack';
449+
450+
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
451+
prefix = prefix.replace(':', '_')
452+
}
453+
if (eclipse.project.name.startsWith(prefix)) {
449454
licenseHeaderFile = new File(project.rootDir, 'buildSrc/src/main/resources/license-headers/elastic-license-header.txt')
450455
} else {
451456
licenseHeaderFile = new File(project.rootDir, 'buildSrc/src/main/resources/license-headers/oss-license-header.txt')
452457
}
453-
String licenseHeader = licenseHeaderFile.getText('UTF-8').replace('\n', '\\\\n')
458+
459+
String lineSeparator = Os.isFamily(Os.FAMILY_WINDOWS) ? '\\\\r\\\\n' : '\\\\n'
460+
String licenseHeader = licenseHeaderFile.getText('UTF-8').replace(System.lineSeparator(), lineSeparator)
454461
task copyEclipseSettings(type: Copy) {
455462
// TODO: "package this up" for external builds
456463
from new File(project.rootDir, 'buildSrc/src/main/resources/eclipse.settings')

0 commit comments

Comments
 (0)