From a0b287c92af86bf67b5a4da8693639077a9e043b Mon Sep 17 00:00:00 2001 From: "R. Tyler Croy" Date: Tue, 18 Aug 2015 10:52:58 -0700 Subject: [PATCH] Prevent JRubyStormLocal task from erroneously using the jrubyExec configuration Fixes #12 --- .../jrubygradle/storm/JRubyStormLocal.groovy | 12 ++++++++ .../storm/JRubyStormLocalSpec.groovy | 30 ++++++++++++++----- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/src/main/groovy/com/github/jrubygradle/storm/JRubyStormLocal.groovy b/src/main/groovy/com/github/jrubygradle/storm/JRubyStormLocal.groovy index 9b215b0..d4e6298 100644 --- a/src/main/groovy/com/github/jrubygradle/storm/JRubyStormLocal.groovy +++ b/src/main/groovy/com/github/jrubygradle/storm/JRubyStormLocal.groovy @@ -1,5 +1,6 @@ package com.github.jrubygradle.storm +import com.github.jrubygradle.internal.JRubyExecUtils import org.gradle.api.tasks.Input import org.gradle.api.tasks.JavaExec @@ -10,9 +11,20 @@ import com.github.jrubygradle.internal.JRubyExecTraits * a given codebase */ class JRubyStormLocal extends JavaExec implements JRubyExecTraits { + static final String DEFAULT_JRUBYSTORMLOCAL_CONFIG = 'jrubyStormLocal' /** parent from which this task will inherit some configuration */ JRubyStorm parentTask + @Input + @Override + String getConfiguration() { + /* Prevent the usage of jrubyExec as our configuration which is never correct */ + if (JRubyExecTraits.super.getConfiguration() == JRubyExecUtils.DEFAULT_JRUBYEXEC_CONFIG) { + return DEFAULT_JRUBYSTORMLOCAL_CONFIG + } + return JRubyExecTraits.super.getConfiguration() + } + /** Set a custom path (relative or absolute) to the file defining a Redstorm topology * * If this is not set, the parentTask's topology will be used diff --git a/src/test/groovy/com/github/jrubygradle/storm/JRubyStormLocalSpec.groovy b/src/test/groovy/com/github/jrubygradle/storm/JRubyStormLocalSpec.groovy index 7323ae6..b132092 100644 --- a/src/test/groovy/com/github/jrubygradle/storm/JRubyStormLocalSpec.groovy +++ b/src/test/groovy/com/github/jrubygradle/storm/JRubyStormLocalSpec.groovy @@ -10,26 +10,24 @@ import org.gradle.testfixtures.ProjectBuilder * */ class JRubyStormLocalSpec extends Specification { - protected Project project + Project project + JRubyStormLocal task void setup() { project = ProjectBuilder.builder().build() project.apply plugin: 'com.github.jruby-gradle.storm' + task = project.task('spock', type: JRubyStormLocal) } def "jrubyStormLocal task should be a proper instance"() { - when: - project.task('jrubyStormLocal', type: JRubyStormLocal) - - then: - project.tasks.jrubyStormLocal instanceof JRubyStormLocal + expect: + task instanceof JRubyStormLocal } def "the task should inherit the topology configured on the parent"() { given: JRubyStorm parent = project.task('spock-parent', type: JRubyStorm) parent.topology = 'foo.rb' - JRubyStormLocal task = project.task('spock', type: JRubyStormLocal) when: task.parentTask = parent @@ -40,7 +38,6 @@ class JRubyStormLocalSpec extends Specification { def "I should be able to set a topology to run without a parent task"() { given: - JRubyStormLocal task = project.task('spock', type: JRubyStormLocal) String topologyFile = 'topology.rb' when: @@ -49,4 +46,21 @@ class JRubyStormLocalSpec extends Specification { then: task.topology == topologyFile } + + @Issue('https://github.com/jruby-gradle/jruby-gradle-storm-plugin/issues/12') + def "default configuration should not be from JRubyExec"() { + expect: + task.configuration == JRubyStormLocal.DEFAULT_JRUBYSTORMLOCAL_CONFIG + } + + def "setting the configuration should work"() { + given: + final String configName = 'someConfiguration' + + when: + task.configuration configName + + then: + task.configuration == configName + } }