Hi
I'm trying to pass an argument from command line to a java class. I
followed this post:
http://gradle.1045684.n5.nabble.com/Gradle-application-plugin-question-td5539555.html
but the code does not work for me (perhaps it is not meant for JavaExec?).
Here is what I tried:
task listTests(type:JavaExec){
main = "util.TestGroupScanner"
classpath = sourceSets.util.runtimeClasspath
// this works...
args 'demo'
/*
// this does not work!
if (project.hasProperty("group")){
args group
}
*/
}
The output from the above hard coded args value is:
C:\ws\svn\sqe\sandbox\selenium2forbg\testgradle>g listTests
:compileUtilJava UP-TO-DATE
:processUtilResources UP-TO-DATE
:utilClasses UP-TO-DATE
:listTests
Received argument: demo
BUILD SUCCESSFUL
Total time: 13.422 secs
However, once I change the code to use the hasProperty section I get a
NullPointerException:
C:\ws\svn\sqe\sandbox\selenium2forbg\testgradle>g listTests -Pgroup=demo -s
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\ws\svn\sqe\sandbox\selenium2forbg\testgradle\build.gradle'
line:
25
* What went wrong:
A problem occurred evaluating root project 'testgradle'.
> java.lang.NullPointerException (no error message)
* Try:
Run with --info or --debug option to get more log output.
* Exception is:
org.gradle.api.GradleScriptException: A problem occurred evaluating root
project
'testgradle'.
at
org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptR
unnerImpl.run(DefaultScriptRunnerFactory.java:54)
at
org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.
apply(DefaultScriptPluginFactory.java:127)
at
org.gradle.configuration.BuildScriptProcessor.evaluate(BuildScriptPro
cessor.java:38)
I'm not sure what is wrong... I'm attaching a simple test project, if
anyone has an idea, please let me know
http://gradle.1045684.n5.nabble.com/file/n5709919/testgradle.zip
testgradle.zip .
Thanks
Lidia
--
View this message in context:
http://gradle.1045684.n5.nabble.com/Passing-argument-from-command-line-to-java-code-tp5709919.html
Sent from the gradle-user mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email