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 + } }