Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I execute ant.java properly from gradle?

I'm trying to invoke a jar, but I don't see any output when I run the command without args, and when I do run with args, I get the following error:

[ant:java] The args attribute is deprecated. Please use nested arg elements.
[ant:java] Java Result: 1

How do I invoke ant.java in such a way that I see output and can pass arguments?

task compressJs(){
  ant.java(jar:"lib/yuicompressor-2.4.6.jar",fork:true,args:['js/file.js', '-o', 'build/js/file.js'])
}
like image 606
Stefan Kendall Avatar asked Aug 09 '11 02:08

Stefan Kendall


1 Answers

Your args should be specified like this:

ant.java(jar:"lib/yuicompressor-2.4.6.jar",fork:true) {
    arg(value: "js/file.js")
    arg(value: "-o")
    arg(value: "build/js/file.js")
}

Pretty much it is the same as you would do with ant except using the Groovy style markup builder instead of XML.

By default your output will go to the screen. If you want to redirect it, set the 'output' property.

like image 171
Chris Dail Avatar answered Sep 22 '22 04:09

Chris Dail