Merge pull request #15 from rtyler/depends-and-assemble
dependsOn and assembleTask delegation
This commit is contained in:
commit
68904a8bf8
|
@ -38,6 +38,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) {
|
||||
|
|
|
@ -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,10 @@ class JRubyStorm extends DefaultTask {
|
|||
/** Configuration which has all of our dependencies */
|
||||
protected Configuration configuration
|
||||
|
||||
Task getAssembleTask() {
|
||||
return assembleTask
|
||||
}
|
||||
|
||||
/** Path (absolute or relative) to the Ruby file containing the topology */
|
||||
@Input
|
||||
String topology
|
||||
|
@ -63,24 +71,13 @@ 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)
|
||||
this.dependsOn assembleTask
|
||||
|
||||
project.afterEvaluate { this.updateDependencies() }
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ class JRubyStormExtension {
|
|||
|
||||
@Incubating
|
||||
/** Default version of redstorm to use */
|
||||
String defaultRedstormVersion = '0.7.2'
|
||||
String defaultRedstormVersion = '0.7.3'
|
||||
|
||||
/** Set the Storm dependency version */
|
||||
void defaultVersion(Object stormVersion) {
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue