I want to run a jar file with parameters located at C:/Users/nwuser/FitNesse/fitnesse-standalone.jar in my gradle script. I know how to do it without parameters:
apply plugin: 'java'
task runJar(dependsOn:jar) << {
javaexec {
main="-jar"; args "C:/Users/nwuser/FitNesse/fitnesse-standalone.jar"
}
}
But now I want to do something similiar like (if using the console):
java -jar fitnesse-standalone.jar -c "FrontPage?suite&format=text"
How can I apply -c "FrontPage?suite&format=text" inside my gradle script?
Kind regards !
If the task you want to pass parameters to is of type JavaExec and you are using Gradle 5, for example the application plugin's run task, then you can pass your parameters through the --args=... command line option. For example gradle run --args="foo --bar=true" .
args is an array, so simply supply your arguments as such:
task runJar(dependsOn:jar) << {
javaexec {
main="-jar";
args = [
"C:/Users/nwuser/FitNesse/fitnesse-standalone.jar",
"-c",
"FrontPage?suite&format=text"
]
}
}
If you're just trying to run a FitNesse test suite with Gradle, you can add the FitNesse jar to your dependencies:
repositories {
mavenCentral()
}
dependencies {
compile 'org.fitnesse:fitnesse:20161106'
}
and define a JavaExec
task like so:
task fitnesse(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
main = 'fitnesseMain.FitNesseMain'
args '-c', 'FrontPage?suite&format=text'
}
And then run:
$ gradle fitnesse
...
Executing command: FrontPage?suite&format=text
--------
0 Tests, 0 Failures 0.091 seconds.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With