[ 
https://issues.apache.org/jira/browse/CB-9971?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15014192#comment-15014192
 ] 

ASF GitHub Bot commented on CB-9971:
------------------------------------

Github user jasongin commented on a diff in the pull request:

    https://github.com/apache/cordova-android/pull/240#discussion_r45386856
  
    --- Diff: bin/templates/cordova/lib/builders/GradleBuilder.js ---
    @@ -211,3 +212,54 @@ module.exports = GradleBuilder;
     function isAutoGenerated(file) {
         return fs.existsSync(file) && fs.readFileSync(file, 
'utf8').indexOf(MARKER) > 0;
     }
    +
    +/**
    + * A special superspawn-like implementation, required to workaround the 
issue
    + *   with java printing some necessary information to stderr instead of 
stdout.
    + *   This function redirects all stderr messages to current process 
stdout. See
    + *   https://issues.apache.org/jira/browse/CB-9971 for explanation.
    + *
    + * @param   {String}    cmd   A command to spawn
    + * @param   {String[]}  args  Command arguments. Note that on Windows 
arguments
    + *   will be concatenated into string and passed to 'cmd.exe' along with 
'/s'
    + *   and '/c' swithces for proper space-in-path handling
    + *
    + * @return  {Promise}        A promise, rejected with error message, if
    + *   underlying command exits with nonzero exit code, fulfilled otherwise
    + */
    +function spawnWithStderrRedirect(cmd, args) {
    +    var opts = { stdio: 'pipe' };
    +
    +    if (process.platform === 'win32') {
    +        // Work around spawn not being able to find .bat files.
    +        var joinedArgs = [cmd]
    +            .concat(args)
    +            .map(function(a){
    +                // Add quotes to arguments which contains whitespaces
    +                if (/^[^"].* .*[^"]/.test(a)) return '"' + a + '"';
    +                return a;
    +            }).join(' ');
    +
    +        args = ['/s', '/c'].concat('"' + joinedArgs + '"');
    +        cmd = 'cmd';
    +        opts.windowsVerbatimArguments = true;
    +    }
    +
    +    return Q.Promise(function (resolve, reject) {
    +        var proc = child_process.spawn(cmd, args, opts);
    +
    +        proc.stdout.on('data', process.stdout.write.bind(process.stdout));
    +        proc.stderr.on('data', function (data) {
    +            var isRedirectNeeded = data.toString().match(/^Picked up 
_JAVA_OPTIONS: /i);
    +            process[isRedirectNeeded ? 'stdout' : 'stderr'].write(data);
    --- End diff --
    
    Are we sure that putting that line on stdout will not cause different 
problems? Would it be better to completely suppress it? I don't think anyone 
actually cares to see it.


> Cordova outputs "Picked up _JAVA_OPTIONS" in stderr
> ---------------------------------------------------
>
>                 Key: CB-9971
>                 URL: https://issues.apache.org/jira/browse/CB-9971
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android
>    Affects Versions: 5.0.0
>         Environment: Windows, Tools for Apache Cordova in Visual Studio
> Cordova 5.4.0
>            Reporter: Michael Braude
>            Assignee: Vladimir Kotikov
>            Priority: Critical
>              Labels: easyfix, windows,
>   Original Estimate: 2h
>  Remaining Estimate: 2h
>
> Starting with version 5.4.0, Cordova now outputs "Picked up _JAVA_OPTIONS: 
> -Xmx512M" to stderr. This breaks clients such as Visual Studio because we 
> interpret messages in stderr to be errors, and this is not an error. So the 
> result is that we show deploy failures to the dev when there are no errors.
> See this for customer impact: 
> http://stackoverflow.com/questions/33603167/vs2015-build-with-cordova-cli5-4-0-shows-deployment-errors
> We can work around this in Visual Studio by using special casing, but Cordova 
> needs to output this in stdout like it did in previous versions



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org

Reply via email to