JavaExec args are not interpreted by the java command

(jaimiewhiteside) #1

I have a task to generate language resources using an in-house jar

task generateResources(dependsOn: 'cleanResources', type: JavaExec){
    main = 'com.i18n.JavaCodeGenerator'
 classpath = files('ext/java/lib/i18neditor.jar')
 args '-basename Resources', '-root src/resources/com', '-output build.output/resources', '-longshort', '-fudd',
'-egg CPC', '-actionclass com.utility.ActionInfo', '-iconclass com.utility.IconStrip', '-public'
 maxHeapSize = '1024m'

When I run the gradle task I get an error generated by the code generator indicating that a required option (-basename) is invalid

When I add -info I can see the args appear to have been added to the command:

Starting process 'command 'C:\Program Files\Java\jdk1.6.0_27\bin\java.exe''. Working directory: C:\source_code4_0 Command: C:\Program Files\Java\jdk1.6.0_27\bin\java.exe -Xmx1024m -Dfile.encoding=windows-1252 -cp C:\source_code4_0\ext\java\lib\i18neditor.jar com.i18n.JavaCodeGenerator -basename Resources -root src/resources/com -output build.output/resources -longshort -fudd -egg CPC -actionclass com.utility.ActionInfo -iconclass com.utility.IconStrip -public

What I find unusual is that if I run the java command generated, it runs without error.

So I’m a bit confused as to what I’ve done wrong.

Executing JavaExec task with jar doesn't take care of arguments
(Luke Daley) #2

I think the problem is that you are grouping args. It should be…

args '-basename', 'Resources'

(jaimiewhiteside) #3

That was it, thank you.