Issue Type: Improvement Improvement
Affects Versions: 1.2.1
Assignee: Unassigned
Attachments: UseConsoleForStdout.patch
Components: exec
Created: 21/Nov/13 10:28 PM
Description:

exec-maven-plugin pipes the output of the executable directly to System.out, which doesn't take into account the character set of the console.

For example, on Windows, if the executable outputs UTF-8 then those UTF-8 bytes are passed directly to System.out, but the DOS character set is Cp437, resulting in potential garbled output of non-ascii characters.

This is a hard problem to solve (detecting the character set to use for console output), but luckily JDK6 introduced System.console(), which handles writing to the console using the correct character set.

(Note: System.console() returns null if the output is not going to a console window, e.g. if it is being redirected to a file.)

I have attached a patch which uses System.console() if available (JDK6) and not null, and otherwise falls back to System.out.

The particular use case I have is running npm (node package manager) from exec-maven-plugin, because npm outputs some UTF-8 (non-ascii) characters to produce a tree-like graph. These characters don't render properly when piped to System.out, but render fine when piped to System.console().

The patch is also viewable at https://github.com/trask/exec-maven-plugin/commit/6b34374fe2f2e89144910ff13db3d53e19c23ca4

I'm happy to update/re-work the patch to address any concerns. Thanks.

Environment: Windows
Project: Mojo's Exec Maven Plugin
Priority: Minor Minor
Reporter: Trask Stalnaker
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
--------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email

Reply via email to