Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport PR #14890 to 8.7: Workaround for #14873 #14892

Merged
merged 1 commit into from
Feb 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion rubyUtils.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ def versionsPath = project.hasProperty("LOGSTASH_CORE_PATH") ? LOGSTASH_CORE_PAT
versionMap = (Map) (new Yaml()).load(new File("${versionsPath}").text)

String jRubyURL
String previousJRubyVersion = "9.3.9.0"
String previousJRubyURL = "https://repo1.maven.org/maven2/org/jruby/jruby-dist/${previousJRubyVersion}/jruby-dist-${previousJRubyVersion}-bin.tar.gz"
String jRubyVersion
String jRubySha1
Boolean doChecksum
Expand All @@ -204,6 +206,7 @@ if (versionMap["jruby-runtime-override"]) {
doChecksum = true
}
def jrubyTarPath = "${projectDir}/vendor/_/jruby-dist-${jRubyVersion}-bin.tar.gz"
def previousJrubyTarPath = "${projectDir}/vendor/_/jruby-dist-${previousJRubyVersion}-bin.tar.gz"

def customJRubyDir = project.hasProperty("custom.jruby.path") ? project.property("custom.jruby.path") : ""
def customJRubyVersion = customJRubyDir == "" ? "" : Files.readAllLines(Paths.get(customJRubyDir, "VERSION")).get(0).trim()
Expand All @@ -218,6 +221,15 @@ tasks.register("downloadJRuby", Download) {
dest new File("${projectDir}/vendor/_", "jruby-dist-${jRubyVersion}-bin.tar.gz")
}

tasks.register("downloadPreviousJRuby", Download) {
description "Download previous JRuby artifact from this specific URL: ${previousJRubyURL}"
src previousJRubyURL
onlyIfNewer true
inputs.file(versionsPath)
outputs.file(previousJrubyTarPath)
dest new File("${projectDir}/vendor/_", "jruby-dist-${previousJRubyVersion}-bin.tar.gz")
}

downloadJRuby.onlyIf { customJRubyDir == "" }

tasks.register("verifyFile", Verify) {
Expand Down Expand Up @@ -262,9 +274,26 @@ tasks.register("installCustomJRuby", Copy) {

installCustomJRuby.onlyIf { customJRubyDir != "" }

tasks.register("downloadAndInstallPreviousJRubyFFI", Copy) {
dependsOn=[downloadPreviousJRuby]
description "Install previous JRuby FFI files in the new JRuby directory"
inputs.file(previousJrubyTarPath)
outputs.dir("${projectDir}/vendor/jruby/tmp")
from tarTree(downloadPreviousJRuby.dest)
eachFile { f ->
f.path = f.path.replaceFirst("^jruby-${previousJRubyVersion}", '')
}
// Copy only the previous builds of libjffi that changed from JRuby 9.3.9.0 to 9.3.10.0
include "**/lib/jni/**/*"

includeEmptyDirs = false
into "${projectDir}/vendor/jruby/tmp"
}


tasks.register("downloadAndInstallJRuby", Copy) {
dependsOn=[verifyFile, installCustomJRuby]
// TODO remove downloadAndInstallPreviousJRubyFFI after https://github.com/elastic/logstash/issues/14873 is fixed
dependsOn=[verifyFile, downloadAndInstallPreviousJRubyFFI, installCustomJRuby]
description "Install JRuby in the vendor directory"
inputs.file(jrubyTarPath)
outputs.dir("${projectDir}/vendor/jruby")
Expand All @@ -274,9 +303,18 @@ tasks.register("downloadAndInstallJRuby", Copy) {
}
exclude "**/stdlib/rdoc/**"
exclude "**/did_you_mean-*/evaluation/**" // licensing issue https://github.com/jruby/jruby/issues/6471
exclude "**/lib/jni/**/**"

includeEmptyDirs = false
into "${projectDir}/vendor/jruby"

doLast {
ant.jar(destfile: "${projectDir}/vendor/jruby/lib/jruby.jar", update: true) {
fileset(dir: "${projectDir}/vendor/jruby/tmp/lib")
}
delete files("${projectDir}/vendor/jruby/tmp")
}

}

downloadAndInstallJRuby.onlyIf { customJRubyDir == "" }
Expand Down