Skip to content

Commit 70531ec

Browse files
committed
Fix license header generation on Windows (#31790)
Updates the build.gradle to take into account the OS differences for Windows (in particular line separator and project naming)
1 parent e7ea338 commit 70531ec

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

build.gradle

+9-2
Original file line numberDiff line numberDiff line change
@@ -439,12 +439,19 @@ allprojects {
439439
}
440440

441441
File licenseHeaderFile;
442-
if (eclipse.project.name.startsWith(':x-pack')) {
442+
String prefix = ':x-pack';
443+
444+
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
445+
prefix = prefix.replace(':', '_')
446+
}
447+
if (eclipse.project.name.startsWith(prefix)) {
443448
licenseHeaderFile = new File(project.rootDir, 'buildSrc/src/main/resources/license-headers/elastic-license-header.txt')
444449
} else {
445450
licenseHeaderFile = new File(project.rootDir, 'buildSrc/src/main/resources/license-headers/oss-license-header.txt')
446451
}
447-
String licenseHeader = licenseHeaderFile.getText('UTF-8').replace('\n', '\\\\n')
452+
453+
String lineSeparator = Os.isFamily(Os.FAMILY_WINDOWS) ? '\\\\r\\\\n' : '\\\\n'
454+
String licenseHeader = licenseHeaderFile.getText('UTF-8').replace(System.lineSeparator(), lineSeparator)
448455
task copyEclipseSettings(type: Copy) {
449456
// TODO: "package this up" for external builds
450457
from new File(project.rootDir, 'buildSrc/src/main/resources/eclipse.settings')

0 commit comments

Comments
 (0)