You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by GitBox <gi...@apache.org> on 2021/04/13 20:22:48 UTC

[GitHub] [cordova-android] rmondegar opened a new issue #1203: java checks in check_reqs.js is incompatible with "javac -version" output

rmondegar opened a new issue #1203:
URL: https://github.com/apache/cordova-android/issues/1203


   # Bug Report
   
   ## Problem
   check_reqs.js fails to retrieve the correct version java. When checking the version using `javac -version`, `semver.coerce` always returns version "8.0.0".
   `javac -version` returns the following output:
   
   ![image](https://user-images.githubusercontent.com/60993939/114612178-2d99e100-9c78-11eb-8e12-24abb2ecca6f.png)
   
   `semver.coerce` uses the first number found and returns this as a version:
   
   ![image](https://user-images.githubusercontent.com/60993939/114612207-368ab280-9c78-11eb-8eb6-50cac5e0b4cc.png)
   
   With this, the needed check fails:
   
   ![image](https://user-images.githubusercontent.com/60993939/114611339-4fdf2f00-9c77-11eb-916a-e94c13a9d9f7.png)
   
   ### What is expected to happen?
   
   Return the correct version, in this case, 1.8.0_282
   
   ### What does actually happen?
   
   Always returns 8 (related to UTF8)
   
   ## Information
   It seems the problem was introduced with the commit 774de786910abd0c83e5b5e285961fcb07c38474 where this check was refactored
   
   ### Command or Code
   `javac -version`
   `cordova build -d`
   
   ```
   import semver = require('semver');
   const version ="Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8\njavac 1.8.0_282"
   console.log(semver.coerce(version));
   ```
   
   ### Environment, Platform, Device
   OS: Ubuntu 18.04.1
   
   ### Version information
   Cordova: 10.0.0
   Plugin list:
   ```
   cordova-hot-code-push-plugin 1.5.3 "Hot Code Push Plugin"
   cordova-plugin-appcenter-analytics 0.5.1 "App Center Analytics for Cordova"
   cordova-plugin-appcenter-crashes 0.5.1 "App Center Crashes for Cordova"
   cordova-plugin-appcenter-shared 0.5.1 "App Center shared code for Cordova"
   cordova-plugin-barcodescanner 0.7.4 "BarcodeScanner"
   cordova-plugin-camera 5.0.1 "Camera"
   cordova-plugin-compat 1.2.0 "Compat"
   cordova-plugin-device 1.1.2 "Device"
   cordova-plugin-file 6.0.2 "File"
   cordova-plugin-geolocation 4.0.2 "Geolocation"
   cordova-plugin-inappbrowser 4.0.0 "InAppBrowser"
   cordova-plugin-media-capture 3.0.3 "Capture"
   cordova-plugin-media 5.0.3 "Media"
   cordova-plugin-openfilenative 1.0.3 "Open File Native"
   cordova-plugin-statusbar 2.4.3 "StatusBar"
   cordova-plugin-whitelist 1.3.5-dev "Whitelist"
   cordova-plugin-wkwebviewxhrfix 1.0.0 "Cordova WKWebView File XHR Fix"
   ```
   `cordova platform ls` output:
   ```
   Installed platforms:
     android 9.1.0
   Available platforms:
     browser ^6.0.0
     electron ^1.0.0
   Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
   javac 1.8.0_282
   SemVer {
     options: {},
     loose: false,
     includePrerelease: false,
     raw: '8.0.0',
     major: 8,
     minor: 0,
     patch: 0,
     prerelease: [],
     build: [],
     version: '8.0.0'
   }
   ```
   
   OS: Ubuntu 18.04.1
   
   ## Checklist
   <!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
   
   - [X] I searched for existing GitHub issues
   - [ ] I updated all Cordova tooling to most recent version
   - [X] I included all the necessary information above


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [cordova-android] rmondegar commented on issue #1203: java checks in check_reqs.js is incompatible with "javac -version" output

Posted by GitBox <gi...@apache.org>.
rmondegar commented on issue #1203:
URL: https://github.com/apache/cordova-android/issues/1203#issuecomment-819043951


   An **untested** fix would probably be the changing line 46 of the file `java.js` with the following (or similar):
   
   ```
               const javacOutput = (await execa('javac', ['-version'], { all: true })).all;
               const match = /javac\s+([\d.]+)/i.exec(javacOutput);
               if (match && match.length > 0) {
                   version = match[1];
               } else {
                   version = javacOutput;
               }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [cordova-android] breautek commented on issue #1203: java checks in check_reqs.js is incompatible with "javac -version" output

Posted by GitBox <gi...@apache.org>.
breautek commented on issue #1203:
URL: https://github.com/apache/cordova-android/issues/1203#issuecomment-819608485


   > An **untested** fix would probably be the changing line 46 of the file `java.js` with the following (or similar):
   > 
   > ```
   >             const javacOutput = (await execa('javac', ['-version'], { all: true })).all;
   >             const match = /javac\s+([\d.]+)/i.exec(javacOutput);
   >             if (match && match.length > 0) {
   >                 version = match[1];
   >             } else {
   >                 version = javacOutput;
   >             }
   > ```
   
   I'll support a PR that adds a test case to https://github.com/apache/cordova-android/blob/master/spec/unit/java.spec.js
   and your proposed solution.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [cordova-android] breautek closed issue #1203: java checks in check_reqs.js is incompatible with "javac -version" output

Posted by GitBox <gi...@apache.org>.
breautek closed issue #1203:
URL: https://github.com/apache/cordova-android/issues/1203


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [cordova-android] breautek commented on issue #1203: java checks in check_reqs.js is incompatible with "javac -version" output

Posted by GitBox <gi...@apache.org>.
breautek commented on issue #1203:
URL: https://github.com/apache/cordova-android/issues/1203#issuecomment-819039665


   Seems like it's a problem with environments that contains the `JAVA_TOOL_OPTIONS` environment variable, which produces additional printout.
   
   Think the best course of action for Cordova is to attempt find the `java`/`javac` line, or at least something that matches a regex of `<number>.<number>.<number>`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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