I have the following two tasks for running FitNesse in different modes:
task fitnesseWiki(type: JavaExec, dependsOn: build) {
classpath configurations.runtime
main "fitnesse.FitNesse"
args '-p', fitnessePort, '-d', fitnesseDir, '-r', fitnesseRoot, '-o'
doFirst {
systemProperties(["maven.classpath": mavenPathAsWikiPaths()])
}
}
task fitnesseTest(type: JavaExec, dependsOn: build) {
classpath configurations.runtime
main "fitnesse.FitNesse"
args '-p', fitnessePort, '-d', fitnesseDir, '-r', fitnesseRoot, '-o', '-c', 'StatisticsTests?suite&format=text'
doFirst {
systemProperties(["maven.classpath": mavenPathAsWikiPaths()])
}
}
def mavenPathAsWikiPaths() {
(configurations.archives.artifacts.files + configurations.runtime.asFileTree).collect {
"!path ${it.path}"
}.join("\n")
}
This works fine, but I’m a bit concerned about the duplication. As you can see, they only differ in the different “args”. Is there a simple way of reducing this duplication? I made some experiments with a custom task class inheriting from JavaExec, but had trouble getting the details right. And I don’t know if that’s the right way.