Creates a cpp gradle module to control the cpp build (elastic/elasticsearch#361)

Also uploads the pack zip to the nas instead of the elasticsearch plugin.

The cpp build can be disabled with `-Pxpack.cpp.build=false`

Original commit: elastic/x-pack-elasticsearch@1efb1b2e7e
This commit is contained in:
Colin Goodheart-Smithe 2016-11-23 11:22:04 +00:00 committed by GitHub
parent d5bb1f603b
commit b295d764a6
3 changed files with 32 additions and 74 deletions

View File

@ -5,6 +5,21 @@ import org.gradle.plugins.ide.eclipse.model.SourceFolder
import org.elasticsearch.gradle.precommit.LicenseHeadersTask import org.elasticsearch.gradle.precommit.LicenseHeadersTask
import org.elasticsearch.gradle.VersionProperties import org.elasticsearch.gradle.VersionProperties
import java.nio.file.Files
import java.nio.file.Paths
import java.nio.file.StandardCopyOption
boolean isWindows = OperatingSystem.current().isWindows()
boolean isLinux = OperatingSystem.current().isLinux()
boolean isMacOsX = OperatingSystem.current().isMacOsX()
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")))
configurations.all { configurations.all {
// check for updates every build // check for updates every build
resolutionStrategy.cacheChangingModulesFor 0, 'seconds' resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
@ -65,47 +80,29 @@ task clean(type: Delete) {
delete 'build' delete 'build'
} }
boolean isLinux = OperatingSystem.current().isLinux() // norelease: this won't be needed when the pluginAll task below is removed
boolean isMacOsX = OperatingSystem.current().isMacOsX() class SimpleCopy extends DefaultTask {
boolean isWindows = OperatingSystem.current().isWindows() String sourceFile;
String destFile;
project.ext.bash = isWindows ? "C:\\Program Files\\Git\\bin\\bash" : "/bin/bash" @TaskAction
project.ext.make = (isMacOsX || isWindows) ? "gnumake" : (isLinux ? "make" : "gmake") def copy() {
project.ext.numCpus = Runtime.runtime.availableProcessors() Files.copy(Paths.get(sourceFile), Paths.get(destFile), StandardCopyOption.REPLACE_EXISTING)
}
task cppClean(type: Exec) {
commandLine bash
args '-c', 'source cpp/set_env.sh && rm -rf cppdistribution && ' + make + ' clean'
} }
task cppObjCompile(type: Exec) { // norelease: by the time we move to x-plugins we cannot use the Prelert NAS at all
commandLine bash task uploadPack(type: SimpleCopy) {
args '-c', 'source cpp/set_env.sh && ' + make + ' -j' + numCpus + ' objcompile' // 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 cppMake(type: Exec) { uploadPack.dependsOn build
commandLine bash
args '-c', 'source cpp/set_env.sh && ' + make + ' -j' + numCpus
}
task cppStrip(type: Exec) { task deploy(dependsOn: uploadPack) {
commandLine bash
args '-c', 'source cpp/set_env.sh && cpp/strip_binaries.sh'
}
task cppTest(type: Exec) {
commandLine bash
args '-c', 'source cpp/set_env.sh && ' + make + ' -j' + numCpus + ' test'
}
task cppAll {
dependsOn 'cppObjCompile'
dependsOn 'cppMake'
dependsOn 'cppStrip'
dependsOn 'cppTest'
tasks.findByName('cppMake').mustRunAfter 'cppObjCompile'
tasks.findByName('cppStrip').mustRunAfter 'cppMake'
tasks.findByName('cppTest').mustRunAfter 'cppStrip'
} }
subprojects { subprojects {

View File

@ -1,22 +1,5 @@
import org.elasticsearch.gradle.precommit.PrecommitTasks import org.elasticsearch.gradle.precommit.PrecommitTasks
import org.gradle.internal.os.OperatingSystem
import java.nio.file.Files
import java.nio.file.Paths
import java.nio.file.StandardCopyOption
boolean isWindows = OperatingSystem.current().isWindows()
boolean isLinux = OperatingSystem.current().isLinux()
boolean isMacOsX = OperatingSystem.current().isMacOsX()
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")))
apply plugin: 'elasticsearch.esplugin' apply plugin: 'elasticsearch.esplugin'
esplugin { esplugin {
@ -27,7 +10,6 @@ esplugin {
version = "${elasticsearchVersion}" version = "${elasticsearchVersion}"
// We need to enable this at some point
thirdPartyAudit.enabled = false thirdPartyAudit.enabled = false
dependencies { dependencies {
@ -67,25 +49,3 @@ bundlePlugin {
includeEmptyDirs = false includeEmptyDirs = false
} }
} }
// 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 pluginAll(type: SimpleCopy) {
// This doesn't use a Copy task because that builds hashes for a huge number of files on the NAS
String zipFile = "${esplugin.name}-${elasticsearchVersion}.zip"
sourceFile = "${projectDir}/build/distributions/" + zipFile
destFile = project.ext.nasDirectory + zipFile.replace('.zip', project.ext.nasExtension)
}
pluginAll.dependsOn check

View File

@ -1,4 +1,5 @@
rootProject.name = 'prelert' rootProject.name = 'prelert'
include ':cpp'
include ':elasticsearch' include ':elasticsearch'
include ':docs' include ':docs'
include ':kibana' include ':kibana'