[GRADLE-58] Windows console closed on build failure Created: 23/Apr/08 Updated: 04/Jan/13 Resolved: 24/Apr/08 |
|
Status: | Resolved |
Project: | Gradle |
Affects Version/s: | 0.1.1 |
Fix Version/s: | 0.1.2 |
Type: | Bug | ||
Reporter: | Adam Pohorecki | Assignee: | Hans Dockter |
Resolution: | Fixed | Votes: | 0 |
Attachments: | gradle.bat sample.zip | ||||||||
Issue Links: |
|
Description |
If an error occurs during build script execution (on Groovy error like MissingMethodException or illegal use of the AntBuilder), the Windows console gets closed immediately. This makes it pretty hard to read the error description (the only way is to redirect script output to some file). |
Comments |
Comment by Adam Pohorecki [ 23/Apr/08 ] |
I think the problem is in the line 122 of gradle.bat: if "%OS%"=="Windows_NT" exit %ERRORLEVEL% I have checked how this is done in Ant, and ant.bat has a similar, but slightly different way of doing this: if "%OS%"=="Windows_NT" color 00 this fixes the problem, but I'm not really sure if this is a correct solution. |
Comment by Adam Pohorecki [ 23/Apr/08 ] |
Modified gradle.bat. This file fixes the problem I encountered, but I'm not sure whether this is a correct solution. |
Comment by Hans Dockter [ 24/Apr/08 ] |
There is the requirement that Gradle returns an non zero exit code if an error has occured. This is very important to us, as our integration tests re;y on this. This seems not to work with the trick above. It seems not to work for Ant either. ByteArrayOutputStream outStream = new ByteArrayOutputStream() ByteArrayOutputStream errStream = new ByteArrayOutputStream() Process proc = ['cmd', '/c', 'ant unknownTask'].execute() proc.consumeProcessOutput(outStream, errStream) proc.waitFor() String output = outStream String error = errStream println proc.exitValue() println "Output" println output println "Error" println error If you use ['cmd', '/c', 'dir unknownDir'] you get a non zero exit value as well as when using {{EXIT 1. I have no idea right how how to find a proper solution for this. What I try to do on windows is to use the System.err to get information about the status and of course remove the "EXIT" statement. |
Comment by Hans Dockter [ 24/Apr/08 ] |
I'm working on a Mac. I have a windows 2000 I'm using via a virtual machine. Could you check the output for the above script with a newer windows version? |
Comment by Adam Pohorecki [ 24/Apr/08 ] |
I have tested both Ant and Gradle using the script you provided above. Ant always returns 0, unmodified Gradle returns 1 and modified returns 0 on error, so no luck. I'll check if any of the other build solutions returns an error code and post the results here. |
Comment by Hans Dockter [ 24/Apr/08 ] |
Such an exe would be very cool. Relying on System.err for error detection is not a good solution. Thanks
|
Comment by Hans Dockter [ 24/Apr/08 ] |
We have a temporary fix which unfortunately returns always zero as an exit value for the windows start script, even in case of an error. Ant is not doing better, but we would like to. Adam is looking into providing an .exe which behaves better. There is a new issue for this: http://jira.codehaus.org/browse/GRADLE-64 |