From ca083054b4179b57e8b3324fa80b89538284b5de Mon Sep 17 00:00:00 2001 From: "R. Tyler Croy" Date: Wed, 9 Sep 2015 15:33:56 -0700 Subject: [PATCH] Ensure that setting of the jrubyVersion for the topology jar works properly This contains some workarounds until jruby-gradle/redstorm#11 is fixed which will allow us to work on JRuby 9k, until then we'll default to the latest stable JRuby 1.7.x branch Fixes #23 --- .../storm/internal/JRubyStormJar.groovy | 17 +++++++++++++-- .../storm/internal/JRubyStormJarSpec.groovy | 21 +++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/main/groovy/com/github/jrubygradle/storm/internal/JRubyStormJar.groovy b/src/main/groovy/com/github/jrubygradle/storm/internal/JRubyStormJar.groovy index 5ace2c4..550593b 100644 --- a/src/main/groovy/com/github/jrubygradle/storm/internal/JRubyStormJar.groovy +++ b/src/main/groovy/com/github/jrubygradle/storm/internal/JRubyStormJar.groovy @@ -16,9 +16,22 @@ class JRubyStormJar extends JRubyJar { /** parent from which this task will inherit some configuration */ JRubyStorm parentTask + /** + * Return the version of JRuby safe for usage in redstorm + */ + @Override + String getJrubyVersion() { + final String inheritedVersion = super.getJrubyVersion() + + /* if our parent has a default version that's 1.7.x, use it */ + if (inheritedVersion.matches(/1.7.(\d+)/)) { + return inheritedVersion + } + /* Default to 1.7.22 */ + return '1.7.22' + } + String mainClass = REDSTORM_MAIN - /* Default to 1.7.22 */ - String jrubyVersion = '1.7.22' @Override String getConfiguration() { diff --git a/src/test/groovy/com/github/jrubygradle/storm/internal/JRubyStormJarSpec.groovy b/src/test/groovy/com/github/jrubygradle/storm/internal/JRubyStormJarSpec.groovy index 796d931..d41de07 100644 --- a/src/test/groovy/com/github/jrubygradle/storm/internal/JRubyStormJarSpec.groovy +++ b/src/test/groovy/com/github/jrubygradle/storm/internal/JRubyStormJarSpec.groovy @@ -37,4 +37,25 @@ class JRubyStormJarSpec extends Specification { expect: "that it has no special appendix in the filename" task.appendix == '' } + + @Issue('https://github.com/jruby-gradle/redstorm/issues/11') + @Issue('https://github.com/jruby-gradle/jruby-gradle-storm-plugin/issues/23') + def 'jrubyVersion should be default to 1.7.xx'() { + given: + JRubyStormJar task = project.task('spock', type: JRubyStormJar) + + expect: + task.jrubyVersion == '1.7.22' + } + + def "Setting jrubyVersion should override the default"() { + given: + final String version = '1.7.21' + JRubyStormJar task = project.task('spock', type: JRubyStormJar) { + jrubyVersion version + } + + expect: + task.jrubyVersion == version + } }