parent
8c3ea3fd26
commit
d7288e23a9
|
@ -1,3 +1,4 @@
|
|||
import java.util.zip.ZipEntry
|
||||
import java.util.zip.ZipFile
|
||||
|
||||
buildscript {
|
||||
|
@ -18,7 +19,7 @@ buildscript {
|
|||
apply plugin: 'com.github.jruby-gradle.storm'
|
||||
|
||||
jrubyStorm {
|
||||
topology 'hello-topology.rb'
|
||||
topology "${rootDir}/hello-topology.rb"
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -35,9 +36,8 @@ task runGradleTest {
|
|||
}
|
||||
/* ensure our outputs contain a valid jar file (aka Zip) */
|
||||
assemble.outputs.files.files.each { File jar ->
|
||||
logger.info("Looking at ${jar}")
|
||||
ZipFile f = new ZipFile(jar)
|
||||
if ((new ZipFile(jar)).size() <= 0) {
|
||||
if (!f.entries().find { ZipEntry ze -> ze.name.matches(/hello-topology.rb/) }) {
|
||||
throw new GradleException("The file ${jar} does not appear to be valid")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,12 +21,6 @@ class JRubyStorm extends DefaultTask {
|
|||
/** Dynamically created dependent task for building the topology jar */
|
||||
private Task assembleTask
|
||||
|
||||
private static final String REDSTORM_MAIN = 'redstorm.TopologyLauncher'
|
||||
private static final List<String> DEFAULT_EXCLUDES = ['*.sw*',
|
||||
'*.gitkeep',
|
||||
'*.md',
|
||||
'META-INF/BCKEY*', ]
|
||||
|
||||
/** Default version of redstorm to use */
|
||||
protected String customRedstormVersion
|
||||
/** Default version of Storm supported included */
|
||||
|
@ -73,8 +67,8 @@ class JRubyStorm extends DefaultTask {
|
|||
super()
|
||||
configuration = project.configurations.maybeCreate(DEFAULT_CONFIGURATION_NAME)
|
||||
this.group JRubyPlugin.TASK_GROUP_NAME
|
||||
this.runTask = JRubyStormInternal.createRunTask(this.project, this.name, this)
|
||||
this.assembleTask = JRubyStormInternal.createAssembleTask(this.project, this.name)
|
||||
this.runTask = JRubyStormInternal.createRunTask(this.project, this)
|
||||
this.assembleTask = JRubyStormInternal.createAssembleTask(this.project, this)
|
||||
|
||||
project.afterEvaluate { this.updateDependencies() }
|
||||
}
|
||||
|
|
|
@ -6,8 +6,11 @@ import org.gradle.api.Task
|
|||
|
||||
|
||||
class JRubyStorm {
|
||||
static Task createAssembleTask(Project project, String baseName) {
|
||||
return project.task("assemble${prepareNameForSuffix(baseName)}", type: JRubyStormJar)
|
||||
static Task createAssembleTask(Project project, Task parent) {
|
||||
JRubyStormJar task = project.task("assemble${prepareNameForSuffix(parent.name)}",
|
||||
type: JRubyStormJar)
|
||||
task.parentTask = parent
|
||||
return task
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -22,8 +25,8 @@ class JRubyStorm {
|
|||
return baseName.replaceAll("(?i)jruby", 'JRuby').capitalize()
|
||||
}
|
||||
|
||||
static Task createRunTask(Project project, String baseName, Task parent) {
|
||||
JRubyStormLocal runTask = project.task("run${prepareNameForSuffix(baseName)}",
|
||||
static Task createRunTask(Project project, Task parent) {
|
||||
JRubyStormLocal runTask = project.task("run${prepareNameForSuffix(parent.name)}",
|
||||
type: JRubyStormLocal)
|
||||
runTask.parentTask = parent
|
||||
return runTask
|
||||
|
|
|
@ -3,6 +3,30 @@ package com.github.jrubygradle.storm.internal
|
|||
import com.github.jrubygradle.jar.JRubyJar
|
||||
import groovy.transform.InheritConstructors
|
||||
|
||||
import com.github.jrubygradle.storm.JRubyStorm
|
||||
|
||||
@InheritConstructors
|
||||
class JRubyStormJar extends JRubyJar {
|
||||
static final String REDSTORM_MAIN = 'redstorm.TopologyLauncher'
|
||||
private static final List<String> DEFAULT_EXCLUDES = ['*.sw*',
|
||||
'*.gitkeep',
|
||||
'*.md',
|
||||
'META-INF/BCKEY*', ]
|
||||
/** parent from which this task will inherit some configuration */
|
||||
JRubyStorm parentTask
|
||||
|
||||
String mainClass = REDSTORM_MAIN
|
||||
|
||||
JRubyStormJar() {
|
||||
super()
|
||||
appendix = ''
|
||||
}
|
||||
|
||||
@Override
|
||||
void copy() {
|
||||
if (parentTask.topology) {
|
||||
into('') { from parentTask.topology }
|
||||
}
|
||||
super.copy()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,40 @@
|
|||
package com.github.jrubygradle.storm.internal
|
||||
|
||||
import com.github.jrubygradle.jar.JRubyJar
|
||||
import org.gradle.api.InvalidUserDataException
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.artifacts.Dependency
|
||||
import org.gradle.api.tasks.bundling.Jar
|
||||
import org.gradle.testfixtures.ProjectBuilder
|
||||
import spock.lang.*
|
||||
|
||||
class JRubyStormJarSpec extends Specification {
|
||||
Project project
|
||||
|
||||
def setup() {
|
||||
project = ProjectBuilder.builder().build()
|
||||
project.apply plugin: 'com.github.jruby-gradle.storm'
|
||||
}
|
||||
def "when constructing the task"() {
|
||||
given:
|
||||
Project project = ProjectBuilder.builder().build()
|
||||
project.apply plugin: 'com.github.jruby-gradle.storm'
|
||||
|
||||
expect: "the task to be a JRubyJar"
|
||||
project.task('spock', type: JRubyStormJar) instanceof JRubyJar
|
||||
}
|
||||
|
||||
def "mainClass should be the TopologyLauncher"() {
|
||||
given:
|
||||
Jar task = project.task('spock', type: JRubyStormJar)
|
||||
|
||||
expect:
|
||||
task.mainClass == JRubyStormJar.REDSTORM_MAIN
|
||||
}
|
||||
|
||||
def "appendix should be empty" () {
|
||||
given:
|
||||
Jar task = project.task('spock', type: JRubyStormJar)
|
||||
|
||||
expect: "that it has no special appendix in the filename"
|
||||
task.appendix == ''
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,29 +1,6 @@
|
|||
package com.github.jrubygradle.storm.internal
|
||||
|
||||
import com.github.jrubygradle.storm.JRubyStormLocal
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.Task
|
||||
import org.gradle.api.tasks.bundling.Jar
|
||||
import org.gradle.testfixtures.ProjectBuilder
|
||||
import spock.lang.*
|
||||
|
||||
class JRubyStormSpec extends Specification {
|
||||
Project project
|
||||
|
||||
def setup() {
|
||||
project = ProjectBuilder.builder().build()
|
||||
project.apply plugin: 'com.github.jruby-gradle.storm'
|
||||
}
|
||||
def "createAssembleTask() should return a Jar type task"() {
|
||||
expect:
|
||||
JRubyStorm.createAssembleTask(project, 'spock') instanceof Jar
|
||||
}
|
||||
|
||||
def "createRunTask() should return a JRubyStormLocal type task"() {
|
||||
given:
|
||||
Task task = project.task('spockParent', type: com.github.jrubygradle.storm.JRubyStorm)
|
||||
|
||||
expect:
|
||||
JRubyStorm.createRunTask(project, 'spock', task) instanceof JRubyStormLocal
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue