Question

I have a application, and in main gradle-file I write:

task myTask {
    def command = "wsimport -s src" + File.separator + "main" + File.separator + "java -d " + classesDir + " path to my WSDL-file -b bindings/bindingFirst.xml -b bindings/bindingSecond.xml>>bindings/OutInfo.log" // Create the String
    def proc = command.execute()                 // Call *execute* on the string
    proc.waitFor()                               // Wait for the command to finish

// Obtain status and output
    println "return code: ${ proc.exitValue()}"
    println "stderr: ${proc.err.text}"
    println "stdout: ${proc.in.text}" // *out* from the external program is *in* for groovy
}

A problem in line: ">>bindings/OutInfo.log", Why?

return code: 1
stderr: Exception in thread "main" com.sun.xml.internal.ws.streaming.XMLReaderException: Unable to create StAX reader or writer
    at com.sun.xml.internal.ws.api.streaming.XMLStreamReaderFactory.create(XMLStreamReaderFactory.java:134)
    at com.sun.tools.internal.ws.wscompile.WsimportOptions.parseBindings(WsimportOptions.java:430)
    at com.sun.tools.internal.ws.wscompile.WsimportTool.run(WsimportTool.java:162)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.sun.tools.internal.ws.Invoker.invoke(Invoker.java:120)
    at com.sun.tools.internal.ws.WsImport.main(WsImport.java:42)
Caused by: java.io.FileNotFoundException: /home/.../exampleWsimport/bindings/bindingSecond.xml>>bindings/OutInfo.log (No such file or directory)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:146)
    at java.io.FileInputStream.<init>(FileInputStream.java:101)
    at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
    at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188)
    at java.net.URL.openStream(URL.java:1037)
    at com.sun.xml.internal.ws.api.streaming.XMLStreamReaderFactory.create(XMLStreamReaderFactory.java:132)
    ... 8 more

How can I write in log-file result of command wsimpot? (In gradle (groovy))

Was it helpful?

Solution

You can't do stream redirection like that, can you try:

def fs = File.separator

def command = "wsimport -s src${fs}main${fs}java -d $classesDir path to my WSDL-file -b bindings${fs}bindingFirst.xml -b bindings${fs}bindingSecond.xml"

new File( 'bindings/OutInfo.log' ).withWriterAppend { out ->
   out << command.execute().text
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top