Compare commits
36 Commits
Author | SHA1 | Date |
---|---|---|
R. Tyler Croy | 5baf5ff1ff | |
R. Tyler Croy | 6c609bf5a9 | |
R. Tyler Croy | bf8d3a0e4e | |
R. Tyler Croy | 036e875653 | |
R. Tyler Croy | 48d3f248ba | |
R. Tyler Croy | 6506a3d5d4 | |
R. Tyler Croy | 2a3f0b709a | |
R. Tyler Croy | 2ad81ecb40 | |
R. Tyler Croy | 980b579549 | |
R. Tyler Croy | 2becff34d2 | |
R. Tyler Croy | 7b1c81004c | |
R. Tyler Croy | 94d7efc522 | |
R. Tyler Croy | 790772a8f7 | |
R. Tyler Croy | 16a7f0886b | |
R. Tyler Croy | ecc92d61a0 | |
R. Tyler Croy | 90499d72da | |
R. Tyler Croy | cc1ef8df32 | |
R. Tyler Croy | 27ec0761d0 | |
R. Tyler Croy | b8f6b9886e | |
R. Tyler Croy | ca083054b4 | |
R. Tyler Croy | a6d92230c9 | |
R. Tyler Croy | 26a8316f49 | |
R. Tyler Croy | 61794ed1d2 | |
R. Tyler Croy | 8b59d41c0d | |
R. Tyler Croy | d60010f797 | |
R. Tyler Croy | d0de027097 | |
R. Tyler Croy | d28608f31f | |
R. Tyler Croy | c70216f1c4 | |
R. Tyler Croy | 6f2631ce45 | |
R. Tyler Croy | a0b287c92a | |
R. Tyler Croy | 998e9961c2 | |
R. Tyler Croy | 68904a8bf8 | |
R. Tyler Croy | 90c92d045d | |
R. Tyler Croy | 8c7e2ddc14 | |
R. Tyler Croy | 2046c89c29 | |
R. Tyler Croy | 2934164708 |
28
.travis.yml
28
.travis.yml
|
@ -1,24 +1,18 @@
|
|||
language: groovy
|
||||
sudo: false
|
||||
|
||||
install:
|
||||
- ./gradlew clean
|
||||
|
||||
- "./gradlew clean"
|
||||
script:
|
||||
- ./gradlew -S -i
|
||||
- ./gradlew -S -i gradleTest
|
||||
|
||||
- "./gradlew -S -i check gradleTest assemble"
|
||||
jdk:
|
||||
- oraclejdk7
|
||||
- oraclejdk8
|
||||
- openjdk7
|
||||
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
|
||||
env: TERM=dumb
|
||||
|
||||
- oraclejdk8
|
||||
- openjdk7
|
||||
env:
|
||||
matrix:
|
||||
- TERM=dumb
|
||||
global:
|
||||
secure: MwCVmyShcCHpe9CAQqveN5FWA4z0H+iYv/pzae0up1pCN9OqTL1h9jHkVoMhOQGw5aQQiptObt+5Y2aNlxSXBDPlpyQHV3EtH1ABJxNbdVNvhm2DACvUgF1uGinP2Gof7hm+2S54vEqAaYSd516lMV741H2CvmpjQhaJNpKeQO0=
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.gradle
|
||||
- "$HOME/.gradle"
|
||||
after_success: "./gradlew bintrayUpload -i -PbintrayUser=rtyler -PbintrayKey=${BINTRAY_KEY}"
|
||||
|
|
34
README.adoc
34
README.adoc
|
@ -1,46 +1,27 @@
|
|||
= JRuby/Gradle Storm Plugin
|
||||
|
||||
image:https://travis-ci.org/jruby-gradle/jruby-gradle-storm-plugin.svg?branch=master["Build Status", link="https://travis-ci.org/jruby-gradle/jruby-gradle-storm-plugin"]
|
||||
|
||||
image::https://api.bintray.com/packages/jruby-gradle/plugins/jruby-gradle-storm-plugin/images/download.svg[link="https://bintray.com/jruby-gradle/plugins/jruby-gradle-storm-plugin/_latestVersion"]
|
||||
|
||||
|
||||
JRuby/Gradle plugin to manage creating Storm topology jars
|
||||
|
||||
== Usage
|
||||
|
||||
**NOTE:** This plugin is stili in a very early stages.
|
||||
|
||||
Including the plugin:
|
||||
|
||||
|
||||
[source, groovy]
|
||||
----
|
||||
buildscript {
|
||||
repositories { jcenter() }
|
||||
dependencies {
|
||||
classpath "com.github.jruby-gradle:jruby-gradle-storm-plugin:0.2.0"
|
||||
classpath "com.github.jruby-gradle:jruby-gradle-storm-plugin:[0.4.4,0.5)"
|
||||
}
|
||||
}
|
||||
----
|
||||
|
||||
|
||||
== Running a "local topology"
|
||||
|
||||
The `JRubyStormLocal` task provides the underlying machinery to run a
|
||||
link:https://github.com/jruby-gradle/redstorm[Redstorm] topology in "local"
|
||||
mode:
|
||||
|
||||
[source, groovy]
|
||||
----
|
||||
import com.github.jrubygradle.storm.JRubyStormLocal
|
||||
|
||||
task runLocalTopology(type: JRubyStormLocal) {
|
||||
// path is considered relative to the working directory
|
||||
// the task is executed in
|
||||
topology 'topologies/example_topology.rb'
|
||||
}
|
||||
----
|
||||
|
||||
Then you can run the local topology with: `./gradlew runLocalTopology`
|
||||
|
||||
NOTE: The Gradle script will block until the local topology is terminated (Ctrl+C)
|
||||
|
||||
|
||||
== Creating a topolog .jar
|
||||
|
||||
|
@ -48,7 +29,4 @@ Creating a topology `.jar` file is useflu when you plan on uploading your
|
|||
topology to a running Storm cluster. *Currently* this plugin will only create
|
||||
that jar for you, it will not upload it.
|
||||
|
||||
By default the plugin will include `bolts/` and `/topologies/` in the generated
|
||||
`.jar` file.
|
||||
|
||||
* `./gradlew jrubyStorm` will create a `.jar` in `build/libs/`
|
||||
|
|
51
build.gradle
51
build.gradle
|
@ -15,13 +15,19 @@ buildscript {
|
|||
apply plugin: 'codenarc'
|
||||
apply plugin: 'groovy'
|
||||
apply plugin: 'maven'
|
||||
apply plugin: 'com.jfrog.bintray'
|
||||
apply from: 'gradle/integration-test.gradle'
|
||||
apply from: 'gradle/releasing.gradle'
|
||||
|
||||
group = 'com.github.jruby-gradle'
|
||||
version = '0.2.0'
|
||||
version = '0.4.4'
|
||||
defaultTasks 'check', 'assemble'
|
||||
|
||||
// Any time we're not expicitly saying "build me a release build" we'll change
|
||||
// the version to -SNAPSHOT
|
||||
if (!(System.env.TRAVIS_TAG as Boolean)) {
|
||||
version = "${version}-SNAPSHOT"
|
||||
}
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
|
@ -38,6 +44,9 @@ dependencies {
|
|||
testCompile ("org.spockframework:spock-core:0.7-groovy-${gradle.gradleVersion.startsWith('1.')?'1.8':'2.0'}") {
|
||||
exclude module : 'groovy-all'
|
||||
}
|
||||
|
||||
/* Used for mocking non interface types */
|
||||
testCompile 'cglib:cglib-nodep:3.1'
|
||||
}
|
||||
|
||||
plugins.withType(JavaPlugin) {
|
||||
|
@ -67,4 +76,42 @@ test {
|
|||
}
|
||||
}
|
||||
|
||||
task sourcesJar(type: Jar) {
|
||||
classifier = 'sources'
|
||||
dependsOn classes
|
||||
from sourceSets.main.allSource
|
||||
}
|
||||
|
||||
artifacts {
|
||||
archives sourcesJar
|
||||
}
|
||||
|
||||
bintray {
|
||||
user = project.bintrayUser
|
||||
key = project.bintrayKey
|
||||
publish = true
|
||||
configurations = ['archives']
|
||||
/*
|
||||
* Only only publish when we're tagging a release and if we've executed on
|
||||
* the JDK7 build. This is to prevent multiple attempts by the build matrix
|
||||
* to publish the artifacts
|
||||
*/
|
||||
dryRun = !((System.env.TRAVIS_TAG as boolean) && (System.env.TRAVIS_JDK_VERSION == 'openjdk7'))
|
||||
|
||||
pkg {
|
||||
userOrg = 'jruby-gradle'
|
||||
repo = 'plugins'
|
||||
name = 'jruby-gradle-storm-plugin'
|
||||
labels = ['jruby','storm','java']
|
||||
|
||||
version {
|
||||
name = project.version
|
||||
vcsTag = "v${project.version}"
|
||||
attributes = ['gradle-plugin' : 'com.github.jruby-gradle.storm:com.github.jruby-gradle:jruby-gradle-storm-plugin']
|
||||
desc = project.description
|
||||
}
|
||||
}
|
||||
}
|
||||
bintrayUpload.dependsOn assemble
|
||||
|
||||
// vim: ft=groovy
|
||||
|
|
|
@ -7,12 +7,11 @@ buildscript {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'com.github.jruby-gradle:jruby-gradle-jar-plugin:1.0.2'
|
||||
/* Replace "%%VERSION%%" with the version of JRuby/Gradle Storm you wish to
|
||||
* use if you want to use this build.gradle outside of gradleTest
|
||||
*/
|
||||
classpath 'com.github.jruby-gradle:jruby-gradle-storm-plugin:%%VERSION%%'
|
||||
//classpath 'com.github.jruby-gradle:jruby-gradle-storm-plugin:0.2.0'
|
||||
classpath 'com.github.jruby-gradle:jruby-gradle-jar-plugin:1.1.4+'
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,4 +4,4 @@ bintrayKey=
|
|||
sourceCompatibility=1.7
|
||||
targetCompatibility=1.7
|
||||
|
||||
jrubyGradleMinVersion=1.0.2
|
||||
jrubyGradleMinVersion=1.1.4
|
||||
|
|
|
@ -47,7 +47,7 @@ task integrationTest(type: Test) {
|
|||
check.dependsOn integrationTest
|
||||
|
||||
gradleTest {
|
||||
versions '2.0', '2.2', '2.4', '2.6'
|
||||
versions '2.0', '2.2', '2.6'
|
||||
dependsOn test, integrationTest, jar
|
||||
}
|
||||
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
apply plugin: 'com.jfrog.bintray'
|
||||
|
||||
task sourcesJar(type: Jar, dependsOn: classes) {
|
||||
classifier = 'sources'
|
||||
from sourceSets.main.allSource
|
||||
}
|
||||
|
||||
artifacts {
|
||||
archives sourcesJar
|
||||
}
|
||||
|
||||
bintray {
|
||||
user = project.bintrayUser
|
||||
key = project.bintrayKey
|
||||
publish = true
|
||||
dryRun = false
|
||||
configurations = ['archives']
|
||||
|
||||
pkg {
|
||||
userOrg = 'jruby-gradle'
|
||||
repo = 'plugins'
|
||||
name = 'jruby-gradle-storm-plugin'
|
||||
labels = ['jruby','storm','java']
|
||||
|
||||
version {
|
||||
name = project.version
|
||||
vcsTag = "v${project.version}"
|
||||
attributes = ['gradle-plugin' : 'com.github.jruby-gradle.storm:com.github.jruby-gradle:jruby-gradle-storm-plugin']
|
||||
desc = 'This plugin encapsulates Storm topology building functionality for JRuby Gradle projects'
|
||||
}
|
||||
}
|
||||
}
|
||||
bintrayUpload.dependsOn assemble
|
Binary file not shown.
|
@ -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
|
||||
|
|
|
@ -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`
|
||||
|
|
|
@ -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 <pre>build</pre> {@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()
|
||||
}
|
||||
|
||||
"""
|
||||
}
|
||||
|
||||
}
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -1,44 +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'
|
||||
|
||||
jrubyStorm {
|
||||
}
|
||||
"""
|
||||
|
|
|
@ -1,26 +1,30 @@
|
|||
package com.github.jrubygradle.storm
|
||||
|
||||
import com.github.jrubygradle.JRubyPlugin
|
||||
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.Incubating
|
||||
import org.gradle.api.Task
|
||||
import org.gradle.api.artifacts.Configuration
|
||||
import org.gradle.api.file.CopySpec
|
||||
import org.gradle.api.tasks.Input
|
||||
import org.gradle.api.tasks.Optional
|
||||
|
||||
import com.github.jrubygradle.storm.internal.JRubyStorm as JRubyStormInternal
|
||||
import org.gradle.api.tasks.bundling.AbstractArchiveTask
|
||||
|
||||
/**
|
||||
* Implement the custom behaviors needed to build a JRubyStorm topology
|
||||
*/
|
||||
@Incubating
|
||||
class JRubyStorm extends DefaultTask {
|
||||
static final String DEFAULT_CONFIGURATION_NAME = 'jrubyStorm'
|
||||
|
||||
/** Dynamically created dependent task for running the topology in local mode*/
|
||||
private Task runTask
|
||||
/** Dynamically created dependent task for building the topology jar */
|
||||
private Task assembleTask
|
||||
/**
|
||||
* Dynamically created dependent task for building the topology jar
|
||||
*/
|
||||
@Delegate
|
||||
AbstractArchiveTask assembleTask
|
||||
|
||||
/** Default version of redstorm to use */
|
||||
protected String customRedstormVersion
|
||||
|
@ -29,6 +33,22 @@ class JRubyStorm extends DefaultTask {
|
|||
/** Configuration which has all of our dependencies */
|
||||
protected Configuration configuration
|
||||
|
||||
Task getAssembleTask() {
|
||||
return assembleTask
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply a task dependency to this task and its child tasks
|
||||
*
|
||||
* @param dependencies
|
||||
* @return this task
|
||||
*/
|
||||
Task dependsOn(Object... dependencies) {
|
||||
assembleTask?.dependsOn(dependencies)
|
||||
runTask?.dependsOn(dependencies)
|
||||
return super.dependsOn(dependencies)
|
||||
}
|
||||
|
||||
/** Path (absolute or relative) to the Ruby file containing the topology */
|
||||
@Input
|
||||
String topology
|
||||
|
@ -63,24 +83,14 @@ class JRubyStorm extends DefaultTask {
|
|||
return configuration ?: project.configurations.findByName(DEFAULT_CONFIGURATION_NAME)
|
||||
}
|
||||
|
||||
@Input
|
||||
@Optional
|
||||
void into(CopySpec spec) {
|
||||
assembleTask.into(spec)
|
||||
}
|
||||
|
||||
@Input
|
||||
@Optional
|
||||
void from(CopySpec spec) {
|
||||
assembleTask.from(spec)
|
||||
}
|
||||
|
||||
JRubyStorm() {
|
||||
super()
|
||||
configuration = project.configurations.maybeCreate(DEFAULT_CONFIGURATION_NAME)
|
||||
this.group JRubyPlugin.TASK_GROUP_NAME
|
||||
this.runTask = JRubyStormInternal.createRunTask(this.project, this)
|
||||
this.assembleTask = JRubyStormInternal.createAssembleTask(this.project, this)
|
||||
runTask = JRubyStormInternal.createRunTask(this.project, this)
|
||||
assembleTask = JRubyStormInternal.createAssembleTask(this.project, this)
|
||||
|
||||
super.dependsOn(assembleTask)
|
||||
group JRubyPlugin.TASK_GROUP_NAME
|
||||
|
||||
project.afterEvaluate { this.updateDependencies() }
|
||||
}
|
||||
|
@ -101,6 +111,7 @@ class JRubyStorm extends DefaultTask {
|
|||
|
||||
project.dependencies.add(localConfiguration.name, "org.apache.storm:storm-core:${stormVersion}")
|
||||
localConfiguration.extendsFrom configuration
|
||||
localConfiguration.extendsFrom project.configurations.findByName(JRubyStormPlugin.CLASSPATH_CONFIGURATION)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,7 +12,7 @@ class JRubyStormExtension {
|
|||
|
||||
@Incubating
|
||||
/** Default version of redstorm to use */
|
||||
String defaultRedstormVersion = '0.7.2'
|
||||
String defaultRedstormVersion = '0.9.2'
|
||||
|
||||
/** Set the Storm dependency version */
|
||||
void defaultVersion(Object stormVersion) {
|
||||
|
|
|
@ -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
|
||||
|
@ -32,16 +44,23 @@ class JRubyStormLocal extends JavaExec implements JRubyExecTraits {
|
|||
JRubyStormLocal() {
|
||||
super()
|
||||
super.setMain 'redstorm.TopologyLauncher'
|
||||
description 'Execute the topology in "local" mode'
|
||||
}
|
||||
|
||||
@Override
|
||||
void exec() {
|
||||
logger.info("JRubyStormLocal parentTask: ${parentTask} (${parentTask.topology})")
|
||||
logger.info("JRubyStormLocal executing with parent (${parentTask}) and topology: ${topology}")
|
||||
super.setArgs(['local', topology])
|
||||
super.setEnvironment getPreparedEnvironment(environment)
|
||||
|
||||
if (parentTask) {
|
||||
super.classpath parentTask.localConfiguration.asPath
|
||||
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)
|
||||
|
|
|
@ -8,6 +8,7 @@ import org.gradle.api.Project
|
|||
/**
|
||||
*/
|
||||
class JRubyStormPlugin implements Plugin<Project> {
|
||||
static final CLASSPATH_CONFIGURATION = 'jrubyStormClasspath'
|
||||
void apply(Project project) {
|
||||
project.apply plugin : 'com.github.jruby-gradle.base'
|
||||
project.apply plugin : 'com.github.jruby-gradle.jar'
|
||||
|
@ -15,14 +16,14 @@ class JRubyStormPlugin implements Plugin<Project> {
|
|||
project.extensions.create('storm', JRubyStormExtension)
|
||||
project.task('jrubyStorm', type: JRubyStorm)
|
||||
|
||||
project.configurations.maybeCreate(CLASSPATH_CONFIGURATION)
|
||||
|
||||
updateRepositories(project)
|
||||
}
|
||||
|
||||
@PackageScope
|
||||
void updateRepositories(Project project) {
|
||||
project.repositories {
|
||||
// jcenter contains the redstorm and gradle dependencies
|
||||
jcenter()
|
||||
// Repositories for Storm dependencies
|
||||
maven { url 'http://clojars.org/repo/' }
|
||||
maven { url 'http://conjars.org/repo/' }
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.github.jrubygradle.storm.internal
|
||||
|
||||
import com.github.jrubygradle.jar.JRubyJar
|
||||
import com.github.jrubygradle.storm.JRubyStormPlugin
|
||||
import groovy.transform.InheritConstructors
|
||||
|
||||
import com.github.jrubygradle.storm.JRubyStorm
|
||||
|
@ -15,22 +16,40 @@ class JRubyStormJar extends JRubyJar {
|
|||
/** parent from which this task will inherit some configuration */
|
||||
JRubyStorm parentTask
|
||||
|
||||
String mainClass = REDSTORM_MAIN
|
||||
/* Default to 1.7.21 <https://github.com/jruby-gradle/redstorm/issues/11> */
|
||||
String jrubyVersion = '1.7.21'
|
||||
/**
|
||||
* Return the version of JRuby safe for usage in redstorm
|
||||
*/
|
||||
@Override
|
||||
String getJrubyVersion() {
|
||||
if (embeddedJRubyVersion == null) {
|
||||
/* Default to 1.7.22 <https://github.com/jruby-gradle/redstorm/issues/11> */
|
||||
return '1.7.22'
|
||||
}
|
||||
return embeddedJRubyVersion
|
||||
}
|
||||
|
||||
@Override
|
||||
String getMainClass() {
|
||||
return REDSTORM_MAIN
|
||||
}
|
||||
|
||||
@Override
|
||||
String getConfiguration() {
|
||||
return parentTask.configuration.name
|
||||
if (parentTask) {
|
||||
return parentTask.configuration.name
|
||||
}
|
||||
return JRubyStorm.DEFAULT_CONFIGURATION_NAME
|
||||
}
|
||||
|
||||
JRubyStormJar() {
|
||||
super()
|
||||
appendix = ''
|
||||
description 'Package a Storm topology jar'
|
||||
|
||||
project.afterEvaluate {
|
||||
this.includeRedstorm()
|
||||
this.includeTopology()
|
||||
this.includeClasspathDependencies()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,4 +67,12 @@ class JRubyStormJar extends JRubyJar {
|
|||
into('') { from parentTask.topology }
|
||||
}
|
||||
}
|
||||
|
||||
void includeClasspathDependencies() {
|
||||
project.configurations.findByName(JRubyStormPlugin.CLASSPATH_CONFIGURATION).files.each { File f ->
|
||||
if (f.name.endsWith(".jar")) {
|
||||
from { project.zipTree(f) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.github.jrubygradle.storm
|
||||
|
||||
import com.github.jrubygradle.storm.internal.JRubyStormJar
|
||||
import org.gradle.api.artifacts.Dependency
|
||||
import spock.lang.*
|
||||
|
||||
|
@ -61,6 +62,39 @@ class JRubyStormSpec extends Specification {
|
|||
runTask.topology == 'spock.rb'
|
||||
}
|
||||
|
||||
def "JRubyStorm task should depend on its assembleTask"() {
|
||||
given:
|
||||
Task task = project.task('spock', type: JRubyStorm)
|
||||
|
||||
expect:
|
||||
task.dependsOn.find { it == task.assembleTask }
|
||||
}
|
||||
|
||||
def "into(destPath) should delegate to the assembleTask"() {
|
||||
given:
|
||||
final String path = "some-path"
|
||||
JRubyStormJar assembleTask = Mock(JRubyStormJar)
|
||||
JRubyStorm task = project.task('spock', type: JRubyStorm)
|
||||
task.assembleTask = assembleTask
|
||||
1 * assembleTask.into(path) >> assembleTask
|
||||
|
||||
expect:
|
||||
task.into(path) == assembleTask
|
||||
}
|
||||
|
||||
def "into(destPath, copySpec) should delegate to the assembleTask"() {
|
||||
given:
|
||||
final String path = "some-path"
|
||||
JRubyStormJar assembleTask = Mock(JRubyStormJar)
|
||||
JRubyStorm task = project.task('spock', type: JRubyStorm)
|
||||
task.assembleTask = assembleTask
|
||||
Closure copySpec = { 1 + 1 }
|
||||
1 * assembleTask.into(path, copySpec) >> assembleTask
|
||||
|
||||
expect:
|
||||
task.into(path, copySpec) == assembleTask
|
||||
}
|
||||
|
||||
def "getStormVersion() should return the storm.defaultStormVersion by default"() {
|
||||
given:
|
||||
JRubyStorm task = project.task('spock', type: JRubyStorm)
|
||||
|
@ -108,6 +142,29 @@ class JRubyStormSpec extends Specification {
|
|||
then:
|
||||
project.configurations.findByName(JRubyStorm.DEFAULT_CONFIGURATION_NAME)
|
||||
}
|
||||
|
||||
@Issue('https://github.com/jruby-gradle/jruby-gradle-storm-plugin/issues/19')
|
||||
def "group should be set by default on the sub-tasks"() {
|
||||
given:
|
||||
JRubyStorm task = project.task('spock', type: JRubyStorm)
|
||||
|
||||
expect:
|
||||
task.assembleTask.group == task.group
|
||||
}
|
||||
|
||||
@Issue('https://github.com/jruby-gradle/jruby-gradle-storm-plugin/issues/31')
|
||||
def "assemble task should depend on whatever the parent dependsOn"() {
|
||||
given:
|
||||
JRubyStorm task = project.task('spock', type: JRubyStorm)
|
||||
Task otherTask = project.task('dependentTask')
|
||||
|
||||
when:
|
||||
task.dependsOn otherTask
|
||||
|
||||
then:
|
||||
task.dependsOn.contains(otherTask)
|
||||
task.assembleTask.dependsOn.contains(otherTask)
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore("For some reason these are running with DEBUG log level and it won't turn off")
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue