Summary: | output is duplicated when using redirector inside exec | ||
---|---|---|---|
Product: | Ant | Reporter: | Martin Stumpf <martinst> |
Component: | Core tasks | Assignee: | Ant Notifications List <notifications> |
Status: | NEW --- | ||
Severity: | normal | CC: | alexander, jakub.neubauer |
Priority: | P2 | ||
Version: | 1.8.1 | ||
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Attachments: |
Java source that outputs 2 lines on stdout and stderr
Ant script that showcases the problem |
Description
Martin Stumpf
2012-07-04 07:57:02 UTC
doesn't seem to happen for me. Can you provide an example build file that demonstrates the behavior? Hi, I'm facing this issue too. But when I run it from console, it works, but when I just redirect the output of the ant (on the commandline, not with any option in build.xml), the error output is duplicated I just reproduced this issue using 1.9.6 It turns out there's a workaround. Here's what produces duplicate output: <exec> <redirector output="logfile" alwayslog="true" append="true" /> </exec> Here's what doesn't (I've added the error="" to point to the exact same file): <exec> <redirector output="logfile" error="logfile" alwayslog="true" append="true" /> </exec> Instead of adding error="" you can also add errorproperty="". Generally, just make sure you don't only provide output="", as it will produce duplicate output to the console when combined with alwayslog="true". Created attachment 37032 [details]
Java source that outputs 2 lines on stdout and stderr
Created attachment 37033 [details]
Ant script that showcases the problem
Confirming this bug on Windows 7, Ant 1.10.5. Use case: Feed <exec>'s stdout and stderr both into the Ant log as well as an outputproperty. Configuration: Use <redirector alwayslog="true" logError="false" outputproperty="myoutput"/> within the <exec> task. Problem: Each stderr line occurs twice in the Ant log, but should occur only once. stdout on Ant log is fine, i.e. only occurs once. stderr and stdout in the outputproperty are fine. Reproduction: Compile the attached DemoOutErr.java into a runnable JAR named DemoOutErr.jar, then run the attached Ant script demouterr.xml. The Java outputs 2 lines on stdout and stderr. The Ant script <exec>s the jar and showcases the problem. Output: C:\temp>ant -f demoouterr.xml Buildfile: C:\temp\demoouterr.xml demo: [exec] Hello on output [exec] News on output [exec] Hello on error [exec] News on error [exec] Hello on error [exec] News on error [echo] [echo] Contents of myoutput: [echo] Hello on output [echo] News on output [echo] Hello on error [echo] News on error BUILD SUCCESSFUL Total time: 0 seconds The workaround that Kostas Filios mentions, also puts stdout and stderr both on the Ant log, but feeds stdout and stderr to different properties. The same can be achieves by using just an outputproperty, but setting logError="true". In these circumstances, the stderr shows only once on the Ant log, as it should. However, if you need to feed stdout and stderr into the same property, the error persists. |