diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index b761216..e8c6bf7 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 6d6ba1f..1b5b778 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Tue Sep 16 15:17:56 PDT 2014 +#Mon Sep 21 11:21:40 PDT 2015 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.7-bin.zip diff --git a/gradlew b/gradlew index 91a7e26..97fac78 100755 --- a/gradlew +++ b/gradlew @@ -42,11 +42,6 @@ case "`uname`" in ;; esac -# For Cygwin, ensure paths are in UNIX format before anything is touched. -if $cygwin ; then - [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` -fi - # Attempt to set APP_HOME # Resolve links: $0 may be a link PRG="$0" @@ -114,6 +109,7 @@ fi if $cygwin ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` diff --git a/src/integTest/groovy/com/github/jrubygradle/storm/JRubyStormIntegrationSpecification.groovy b/src/integTest/groovy/com/github/jrubygradle/storm/JRubyStormIntegrationSpecification.groovy new file mode 100644 index 0000000..0126fe1 --- /dev/null +++ b/src/integTest/groovy/com/github/jrubygradle/storm/JRubyStormIntegrationSpecification.groovy @@ -0,0 +1,52 @@ +package com.github.jrubygradle.storm + +import org.gradle.testkit.runner.GradleRunner +import org.gradle.testkit.runner.TaskOutcome +import org.gradle.testkit.runner.BuildResult +import org.junit.Rule +import org.junit.rules.TemporaryFolder +import spock.lang.* + +/** + * Integration testing base class for common integration testing behaviors + */ +class JRubyStormIntegrationSpecification extends Specification { + @Rule + final TemporaryFolder testProjectDir = new TemporaryFolder() + File buildFile + String pluginDependencies + + def setup() { + buildFile = testProjectDir.newFile('build.gradle') + def pluginClasspathResource = getClass().classLoader.findResource("plugin-classpath.json") + + if (pluginClasspathResource == null) { + throw new IllegalStateException("Did not find plugin classpath resource, run `testClasses` build task.") + } + + pluginDependencies = pluginClasspathResource.text + } + + /** + * Apply the necessary plugin configuration to integration test a Gradle build + * with the given
build
{@code File} + * + * @param build Temporary file representing the build.gradle + */ + void applyPluginTo(File build) { + build << """ +buildscript { + dependencies { + classpath files(${pluginDependencies}) + } +} +apply plugin: 'com.github.jruby-gradle.storm' + +repositories { + jcenter() +} + +""" + } + +} diff --git a/src/integTest/groovy/com/github/jrubygradle/storm/JRubyStormLocalIntegrationSpec.groovy b/src/integTest/groovy/com/github/jrubygradle/storm/JRubyStormLocalIntegrationSpec.groovy new file mode 100644 index 0000000..a8142d0 --- /dev/null +++ b/src/integTest/groovy/com/github/jrubygradle/storm/JRubyStormLocalIntegrationSpec.groovy @@ -0,0 +1,111 @@ +package com.github.jrubygradle.storm + +import org.gradle.testkit.runner.GradleRunner +import org.gradle.testkit.runner.TaskOutcome +import org.gradle.testkit.runner.BuildResult +import spock.lang.* + +/** + */ +class JRubyStormLocalIntegrationSpec extends JRubyStormIntegrationSpecification { + def "executing runJRubyStorm with no topology should error"() { + given: + applyPluginTo(buildFile) + buildFile << "jrubyStorm { topology 'foo.rb' }" + + when: + BuildResult result = GradleRunner.create() + .withProjectDir(testProjectDir.root) + .withArguments('runJRubyStorm') + .buildAndFail() + + then: + result.task(":runJRubyStorm").outcome == TaskOutcome.FAILED + } + + File createHelloWorldTopology() { + File topologyFile = testProjectDir.newFile('topo.rb') + topologyFile << """ +require 'red_storm' + +class HelloWorldSpout < RedStorm::DSL::Spout + on_init {@words = ["hello", "world"]} + on_send {@words.shift unless @words.empty?} +end + +class HelloWorldBolt < RedStorm::DSL::Bolt + on_receive :emit => false do |tuple| + puts tuple + end +end + +class HelloWorldTopology < RedStorm::DSL::Topology + spout HelloWorldSpout do + output_fields :word + end + + bolt HelloWorldBolt do + source HelloWorldSpout, :global + end + + configure do + debug false + max_task_parallelism 4 + num_workers 1 + max_spout_pending 1000 + end + + on_submit do + Thread.start { + sleep 20 + cluster.shutdown + } + 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() + .withProjectDir(testProjectDir.root) + .withArguments('runJRubyStorm') + .build() + + then: 'the task should succeed' + result.task(":runJRubyStorm").outcome == TaskOutcome.SUCCESS + + and: "it should have logged hello world" + 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 + } +} diff --git a/src/integTest/groovy/com/github/jrubygradle/storm/JRubyStormTaskIntegrationSpec.groovy b/src/integTest/groovy/com/github/jrubygradle/storm/JRubyStormTaskIntegrationSpec.groovy index 415ea79..32e8fc8 100644 --- a/src/integTest/groovy/com/github/jrubygradle/storm/JRubyStormTaskIntegrationSpec.groovy +++ b/src/integTest/groovy/com/github/jrubygradle/storm/JRubyStormTaskIntegrationSpec.groovy @@ -1,49 +1,32 @@ package com.github.jrubygradle.storm -import org.gradle.api.Project -import org.gradle.testfixtures.ProjectBuilder import org.gradle.testkit.runner.GradleRunner import org.gradle.testkit.runner.TaskOutcome import org.gradle.testkit.runner.BuildResult -import org.gradle.api.artifacts.Dependency -import org.junit.Rule -import org.junit.rules.TemporaryFolder import spock.lang.* /** Integration tests which actually execute Gradle via the GradleTestKit */ -class JRubyStormTestKitSpec extends Specification { - @Rule - final TemporaryFolder testProjectDir = new TemporaryFolder() - File buildFile - String pluginDependencies +class JRubyStormTestKitSpec extends JRubyStormIntegrationSpecification { + def "executing the task without a topolgoy should error"() { + given: + applyPluginTo(buildFile) + buildFile << 'jrubyStorm { }' - def setup() { - buildFile = testProjectDir.newFile('build.gradle') - def pluginClasspathResource = getClass().classLoader.findResource("plugin-classpath.json") + when: + BuildResult result = GradleRunner.create() + .withProjectDir(testProjectDir.root) + .withArguments('jrubyStorm') + .buildAndFail() - if (pluginClasspathResource == null) { - throw new IllegalStateException("Did not find plugin classpath resource, run `testClasses` build task.") - } - - pluginDependencies = pluginClasspathResource.text + then: + result.task(":jrubyStorm").outcome == TaskOutcome.FAILED } def "executing the assemble task produces a jar artifact"() { given: + applyPluginTo(buildFile) buildFile << """ -buildscript { - dependencies { - classpath files(${pluginDependencies}) - } -} -apply plugin: 'com.github.jruby-gradle.storm' - -repositories { - jcenter() - mavenLocal() -} - jrubyStorm { } """ diff --git a/src/main/groovy/com/github/jrubygradle/storm/JRubyStormLocal.groovy b/src/main/groovy/com/github/jrubygradle/storm/JRubyStormLocal.groovy index af4626f..9a8a1d8 100644 --- a/src/main/groovy/com/github/jrubygradle/storm/JRubyStormLocal.groovy +++ b/src/main/groovy/com/github/jrubygradle/storm/JRubyStormLocal.groovy @@ -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()