centralise detection of operating system

Original commit: elastic/x-pack-elasticsearch@0ba41dde0d
This commit is contained in:
Colin Goodheart-Smithe 2016-12-02 12:18:51 +00:00
parent 00dc347217
commit ea1c8b5ddd

View File

@ -19,19 +19,11 @@ project.ext.awsSecretKey = AWS_SECRET_KEY
}
boolean isWindows = OperatingSystem.current().isWindows()
boolean isLinux = OperatingSystem.current().isLinux()
boolean isMacOsX = OperatingSystem.current().isMacOsX()
project.ext.isWindows = OperatingSystem.current().isWindows()
project.ext.isLinux = OperatingSystem.current().isLinux()
project.ext.isMacOsX = OperatingSystem.current().isMacOsX()
project.ext.bash = isWindows ? "C:\\Program Files\\Git\\bin\\bash" : "/bin/bash"
// norelease: replace with something else when we become part of x-plugins
project.ext.nasDirectory = isWindows ? "\\\\prelert-nas\\builds\\6.5.0\\" :
(isMacOsX ? "/Volumes/builds/6.5.0/" : "/export/builds/6.5.0/")
// norelease: replace with something else when we become part of x-plugins
project.ext.nasExtension = '_' + (System.getenv()['GIT_COMMIT'] ?: 'xxxxxxxxxxxxxx').substring(0, 14) +
(isWindows ? "_windows-x86_64.zip" : (isMacOsX ? "_darwin-x86_64.zip" :
(isLinux ? "_linux-x86_64.zip" : "_sunos-x86_64.zip")))
project.ext.bash = project.isWindows ? "C:\\Program Files\\Git\\bin\\bash" : "/bin/bash"
String uploadEnabledStr = properties.get('upload', 'false')
if (['true', 'false'].contains(uploadEnabledStr) == false) {
@ -126,25 +118,6 @@ task clean(type: Delete) {
delete 'build'
}
// norelease: this won't be needed when the pluginAll task below is removed
class SimpleCopy extends DefaultTask {
String sourceFile;
String destFile;
@TaskAction
def copy() {
Files.copy(Paths.get(sourceFile), Paths.get(destFile), StandardCopyOption.REPLACE_EXISTING)
}
}
// norelease: by the time we move to x-plugins we cannot use the Prelert NAS at all
task uploadPack(type: SimpleCopy, dependsOn: [build]) {
// This doesn't use a Copy task because that builds hashes for a huge number of files on the NAS
String zipFile = "prelert-${elasticsearchVersion}.zip"
sourceFile = "${projectDir}/build/distributions/" + zipFile
destFile = project.ext.nasDirectory + zipFile.replace('.zip', project.ext.nasExtension)
}
task uploadPackToS3(type: UploadS3Task, dependsOn: [build]) {
enabled project.uploadEnabled
description = 'upload pack zip to S3 Bucket'