mirror of
https://github.com/elastic/logstash.git
synced 2025-04-19 20:27:23 -04:00
235 lines
8.2 KiB
Groovy
235 lines
8.2 KiB
Groovy
buildscript {
|
|
repositories {
|
|
mavenCentral()
|
|
}
|
|
dependencies {
|
|
classpath 'org.yaml:snakeyaml:1.17'
|
|
}
|
|
}
|
|
|
|
plugins {
|
|
id "de.undercouch.download" version "3.2.0"
|
|
}
|
|
|
|
apply plugin: 'de.undercouch.download'
|
|
|
|
import de.undercouch.gradle.tasks.download.Download
|
|
import de.undercouch.gradle.tasks.download.Verify
|
|
import org.logstash.gradle.ExecLogOutputStream
|
|
import org.yaml.snakeyaml.Yaml
|
|
|
|
allprojects {
|
|
group = 'org.logstash'
|
|
|
|
apply plugin: 'java'
|
|
apply plugin: 'idea'
|
|
|
|
project.sourceCompatibility = JavaVersion.VERSION_1_8
|
|
project.targetCompatibility = JavaVersion.VERSION_1_8
|
|
|
|
tasks.withType(JavaCompile).all {
|
|
def env = System.getenv()
|
|
boolean ci = env['CI']
|
|
|
|
//don't lint when running CI builds
|
|
if(!ci){
|
|
options.compilerArgs.add("-Xlint:all")
|
|
}
|
|
}
|
|
|
|
clean {
|
|
delete "${projectDir}/out/"
|
|
}
|
|
|
|
//https://stackoverflow.com/questions/3963708/gradle-how-to-display-test-results-in-the-console-in-real-time
|
|
tasks.withType(Test) {
|
|
testLogging {
|
|
// set options for log level LIFECYCLE
|
|
events "passed", "skipped", "failed", "standardOut"
|
|
showExceptions true
|
|
exceptionFormat "full"
|
|
showCauses true
|
|
showStackTraces true
|
|
|
|
// set options for log level DEBUG and INFO
|
|
debug {
|
|
events "started", "passed", "skipped", "failed", "standardOut", "standardError"
|
|
exceptionFormat "full"
|
|
}
|
|
info.events = debug.events
|
|
info.exceptionFormat = debug.exceptionFormat
|
|
|
|
afterSuite { desc, result ->
|
|
if (!desc.parent) { // will match the outermost suite
|
|
def output = "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)"
|
|
def startItem = '| ', endItem = ' |'
|
|
def repeatLength = startItem.length() + output.length() + endItem.length()
|
|
println('\n' + ('-' * repeatLength) + '\n' + startItem + output + endItem + '\n' + ('-' * repeatLength))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// fetch version from Logstash's master versions.yml file
|
|
def versionMap = (Map) (new Yaml()).load(new File("${projectDir}/versions.yml").text)
|
|
version = versionMap['logstash-core']
|
|
|
|
String jRubyURL
|
|
String jRubyVersion
|
|
String jRubySha1
|
|
Boolean doChecksum
|
|
|
|
if (versionMap["jruby-runtime-override"]) {
|
|
jRubyVersion = versionMap["jruby-runtime-override"]["version"]
|
|
jRubyURL = versionMap["jruby-runtime-override"]["url"]
|
|
doChecksum = false
|
|
} else {
|
|
jRubyVersion = versionMap["jruby"]["version"]
|
|
jRubySha1 = versionMap["jruby"]["sha1"]
|
|
jRubyURL = "http://jruby.org.s3.amazonaws.com/downloads/${jRubyVersion}/jruby-bin-${jRubyVersion}.tar.gz"
|
|
doChecksum = true
|
|
}
|
|
|
|
// Tasks
|
|
|
|
clean {
|
|
delete "${projectDir}/Gemfile"
|
|
delete "${projectDir}/Gemfile.lock"
|
|
delete "${projectDir}/vendor"
|
|
delete "${projectDir}/NOTICE.TXT"
|
|
}
|
|
|
|
task bootstrap {}
|
|
|
|
project(":logstash-core") {
|
|
["rubyTests", "test"].each { tsk ->
|
|
tasks.getByPath(":logstash-core:" + tsk).configure {
|
|
dependsOn bootstrap
|
|
}
|
|
}
|
|
}
|
|
|
|
task downloadJRuby(type: Download) {
|
|
description "Download JRuby artifact from this specific URL: ${jRubyURL}"
|
|
src jRubyURL
|
|
onlyIfNewer true
|
|
dest new File("${projectDir}/vendor/_", "jruby-bin-${jRubyVersion}.tar.gz")
|
|
}
|
|
|
|
task verifyFile(dependsOn: downloadJRuby, type: Verify) {
|
|
description "Verify the SHA1 of the download JRuby artifact"
|
|
src new File("${projectDir}/vendor/_/jruby-bin-${jRubyVersion}.tar.gz")
|
|
algorithm 'SHA-1'
|
|
checksum jRubySha1
|
|
}
|
|
|
|
task downloadAndInstallJRuby(dependsOn: verifyFile, type: Copy) {
|
|
description "Install JRuby in the vendor directory"
|
|
inputs.files file("${projectDir}/versions.yml")
|
|
outputs.files fileTree("${projectDir}/vendor/jruby")
|
|
from tarTree(downloadJRuby.dest)
|
|
eachFile { f ->
|
|
f.path = f.path.replaceFirst("^jruby-${jRubyVersion}", '')
|
|
}
|
|
exclude "**/stdlib/rdoc/**"
|
|
includeEmptyDirs = false
|
|
into "${projectDir}/vendor/jruby"
|
|
}
|
|
|
|
def jrubyBin = "${projectDir}/vendor/jruby/bin/jruby" +
|
|
(System.getProperty("os.name").startsWith("Windows") ? '.bat' : '')
|
|
|
|
def rakeBin = "${projectDir}/vendor/jruby/bin/rake"
|
|
|
|
task installTestGems(dependsOn: downloadAndInstallJRuby, type: Exec) {
|
|
workingDir projectDir
|
|
inputs.files file("${projectDir}/Gemfile.template")
|
|
inputs.files fileTree("${projectDir}/rakelib")
|
|
inputs.files file("${projectDir}/versions.yml")
|
|
outputs.files file("${projectDir}/Gemfile")
|
|
outputs.files file("${projectDir}/Gemfile.lock")
|
|
outputs.files fileTree("${projectDir}/vendor/bundle/gems")
|
|
outputs.files fileTree("${projectDir}/vendor/jruby")
|
|
// Override z_rubycheck.rb because we execute the vendored JRuby and don't have to guard against
|
|
// any Ruby environment leaking into the build
|
|
environment "USE_RUBY", "1"
|
|
standardOutput = new ExecLogOutputStream(System.out)
|
|
errorOutput = new ExecLogOutputStream(System.err)
|
|
commandLine jrubyBin, rakeBin, "test:install-core"
|
|
}
|
|
|
|
task assembleTarDistribution(dependsOn: installTestGems, type: Exec) {
|
|
workingDir projectDir
|
|
inputs.files fileTree("${projectDir}/rakelib")
|
|
inputs.files fileTree("${projectDir}/bin")
|
|
inputs.files fileTree("${projectDir}/config")
|
|
inputs.files fileTree("${projectDir}/lib")
|
|
inputs.files fileTree("${projectDir}/modules")
|
|
inputs.files fileTree("${projectDir}/logstash-core-plugin-api")
|
|
inputs.files fileTree("${projectDir}/logstash-core/lib")
|
|
inputs.files fileTree("${projectDir}/logstash-core/src")
|
|
outputs.files file("${buildDir}/logstash-${project.version}.tar.gz")
|
|
standardOutput = new ExecLogOutputStream(System.out)
|
|
errorOutput = new ExecLogOutputStream(System.err)
|
|
commandLine jrubyBin, rakeBin, "artifact:tar"
|
|
}
|
|
|
|
def logstashBuildDir = "${buildDir}/logstash-${project.version}-SNAPSHOT"
|
|
|
|
task unpackTarDistribution(dependsOn: assembleTarDistribution, type: Copy) {
|
|
def tar = file("${buildDir}/logstash-${project.version}-SNAPSHOT.tar.gz")
|
|
inputs.files tar
|
|
outputs.files fileTree(logstashBuildDir)
|
|
from tarTree(tar)
|
|
into {buildDir}
|
|
}
|
|
|
|
def bundleBin = "${projectDir}/vendor/bundle/jruby/2.3.0/bin/bundle"
|
|
def gemPath = "${buildDir}/qa/integration/gems"
|
|
|
|
task installIntegrationTestBundler(dependsOn: unpackTarDistribution, type: Exec) {
|
|
outputs.files fileTree("${gemPath}/gems/bundler-1.16.0")
|
|
environment "GEM_PATH", gemPath
|
|
environment "GEM_HOME", gemPath
|
|
standardOutput = new ExecLogOutputStream(System.out)
|
|
errorOutput = new ExecLogOutputStream(System.err)
|
|
commandLine jrubyBin, "${projectDir}/vendor/jruby/bin/gem", "install", "bundler", "-v", "1.16.0"
|
|
}
|
|
|
|
task installIntegrationTestGems(dependsOn: installIntegrationTestBundler, type: Exec) {
|
|
workingDir "${projectDir}/qa/integration"
|
|
environment "GEM_PATH", gemPath
|
|
environment "GEM_HOME", gemPath
|
|
inputs.files file("${projectDir}/qa/integration/Gemfile")
|
|
inputs.files file("${logstashBuildDir}/Gemfile")
|
|
inputs.files file("${logstashBuildDir}/Gemfile.lock")
|
|
inputs.files file("${logstashBuildDir}/logstash-core/logstash-core.gemspec")
|
|
inputs.files file("${projectDir}/qa/integration/integration_tests.gemspec")
|
|
outputs.files fileTree("${gemPath}/gems")
|
|
outputs.files file("${projectDir}/qa/integration/Gemfile.lock")
|
|
standardOutput = new ExecLogOutputStream(System.out)
|
|
errorOutput = new ExecLogOutputStream(System.err)
|
|
commandLine jrubyBin, bundleBin, "install"
|
|
}
|
|
|
|
def rubyIntegrationSpecs = project.hasProperty("rubyIntegrationSpecs") ? ((String) project.property("rubyIntegrationSpecs")).split(/\s+/) : []
|
|
|
|
task runIntegrationTests(dependsOn: installIntegrationTestGems, type: Exec) {
|
|
workingDir "${projectDir}/qa/integration"
|
|
environment "JAVA_OPTS", ""
|
|
environment "GEM_PATH", gemPath
|
|
environment "GEM_HOME", gemPath
|
|
// FEATURE_FLAG is set in the CI to configure testing with enabled PQ
|
|
environment "FEATURE_FLAG", System.getenv('FEATURE_FLAG')
|
|
standardOutput = new ExecLogOutputStream(System.out)
|
|
errorOutput = new ExecLogOutputStream(System.err)
|
|
commandLine([jrubyBin, bundleBin, "exec", "rspec"].plus((Collection<String>)rubyIntegrationSpecs))
|
|
}
|
|
|
|
// If you are running a JRuby snapshot we will skip the integrity check.
|
|
verifyFile.onlyIf { doChecksum }
|
|
bootstrap.dependsOn installTestGems
|
|
|
|
runIntegrationTests.shouldRunAfter tasks.getByPath(":logstash-core:test")
|
|
check.dependsOn runIntegrationTests
|