Running EasyB Specs From Gradle
Although the cookbook includes an example of using the easyb ant task to run specs and produce reports, I thought I’d try my hand at writing a task to manually run easyb specifications from the commandline. Here’s the result:
task spec <<{
ant.java(classname:'org.easyb.BehaviorRunner', fork:false,
classpath: "${sourceSets.test.runtimeClasspath.asPath}") {
sourceSets.test.java.srcDirs.each { testDir ->
testDir.eachDirRecurse { dir ->
dir.eachFileMatch(~/.*\.specification/){spec->
arg(value:spec.absolutePath)
}
}
}
}
}
Now I can run “gradle spec” from the commandline to write all my easyb specs. Spock is next.
I’ll admit I’ve just recently gotten back into groovy, so I’m still kind of a noob. I keep feeling like groovy has a better way to search for file patterns recursively. ![]()
If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!














February 14th, 2010 at 3:11 pm
Hi James,
alternatively you can use the Gradle API for the filtering.
sourceSets.java.allSource.matching { include “**/*.specification” }.each { specFile ->
arg(value: specFile)
}
February 14th, 2010 at 5:05 pm
Thanks a lot Hans!