If no parentTask for JRubyStormLocal is set, use the default configuration for the classpath

Fixes #29
This commit is contained in:
R. Tyler Croy 2015-09-21 15:59:39 -07:00
parent 2a3f0b709a
commit 6506a3d5d4
No known key found for this signature in database
GPG Key ID: 1426C7DC3F51E16F
2 changed files with 38 additions and 5 deletions

View File

@ -23,11 +23,7 @@ class JRubyStormLocalIntegrationSpec extends JRubyStormIntegrationSpecification
result.task(":runJRubyStorm").outcome == TaskOutcome.FAILED
}
def "running in local mode with a basic topology"() {
given:
applyPluginTo(buildFile)
buildFile << "jrubyStorm { topology 'topo.rb' }"
File createHelloWorldTopology() {
File topologyFile = testProjectDir.newFile('topo.rb')
topologyFile << """
require 'red_storm'
@ -67,6 +63,14 @@ class HelloWorldTopology < RedStorm::DSL::Topology
end
end
"""
return topologyFile
}
def "running in local mode with a basic topology"() {
given:
applyPluginTo(buildFile)
File topo = createHelloWorldTopology()
buildFile << "jrubyStorm { topology '${topo.absolutePath}' }"
when: 'runJRubyStorm is invoked'
BuildResult result = GradleRunner.create()
@ -81,4 +85,27 @@ end
result.standardOutput.contains('{"word"=>"hello"}')
result.standardOutput.contains('{"word"=>"world"}')
}
@Issue('https://github.com/jruby-gradle/jruby-gradle-storm-plugin/issues/29')
def "JRubyStormLocal tasks should not require a parent task"() {
given:
applyPluginTo(buildFile)
File topo = createHelloWorldTopology()
buildFile << """
import com.github.jrubygradle.storm.JRubyStormLocal
task run(type: JRubyStormLocal) {
topology '${topo.absolutePath}'
}
"""
when: 'the run task is invoked'
BuildResult result = GradleRunner.create()
.withProjectDir(testProjectDir.root)
.withArguments('run')
.build()
then: 'the task should succeed'
result.task(":run").outcome == TaskOutcome.SUCCESS
}
}

View File

@ -56,6 +56,12 @@ class JRubyStormLocal extends JavaExec implements JRubyExecTraits {
if (parentTask) {
super.classpath parentTask.localConfiguration
}
else {
/* make sure we always have some form of valid classpath set, see
* also: https://github.com/jruby-gradle/jruby-gradle-storm-plugin/issues/29
*/
super.classpath project.configurations.findByName(getConfiguration())
}
prepareDependencies(project)
super.exec()