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/26 12:43:51 UTC

[GitHub] [cordova-android] DavidStrausz opened a new pull request #1220: fix(requirements check): use regex to get java version from javac output

DavidStrausz opened a new pull request #1220:
URL: https://github.com/apache/cordova-android/pull/1220


   ### Platforms affected
   Android
   
   ### Motivation and Context
   Fixes getting the java version from the `javac -version` output on macOS devices when custom `_JAVA_OPTIONS` are set. A detailed description of the issue can be found im my comment [here](https://github.com/apache/cordova-android/pull/1130#issuecomment-824749304).
   
   ### Description
   Use a regex to get just the version string from the `javac` output. Fixes #1130.
   
   Previously `semver.coerce()` would get a wrong version from a string like the following:
   
   ```js
   Picked up _JAVA_OPTIONS: -Xms1024M -Xmx2048M\njavac 1.8.0_271
   ```
   
   With the change in this PR, the following regex is used to get the version string (`1.8.0`) from the output:
   
   ```js
   /javac\s+([\d.]+)/i
   ```
   
   I also tried removing `_JAVA_OPTIONS` from the version check by adding `env: {}, extendEnv: false` to the options of the `javac` command like suggested [here](https://github.com/apache/cordova-android/pull/1130#issuecomment-826084254):
   
   ```js
   execa('javac', ['-version'], { all: true, env: {}, extendEnv: false })
   ```
   
   This changed the output from:
   
   ```js
   Picked up _JAVA_OPTIONS: -Xms1024M -Xmx2048M\njavac 1.8.0_271
   ```
   
   to:
   
   ```js
   javac 12.0.2
   ```
   
   which subsequently let the requirements check fail again (no idea where `12.0.2` comes from). So I just went with the regex solution.
   
   ### Testing
   - Add android platform with fix on macOS, run `cordova build android`, check if requirements check succeeds
   - Add android platform with fix on Windows, run `cordova build android`, check if requirements check succeeds
   - Add unit test for `javac -version` output with `_JAVA_OPTIONS`, run unit tests
   
   ### Checklist
   
   - [x] I've run the tests to see all new and existing tests pass
   - [x] I added automated test coverage as appropriate for this change
   - [ ] Commit is prefixed with `(platform)` if this change only applies to one platform (e.g. `(android)`)
   - [x] If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct [keyword to close issues using keywords](https://help.github.com/articles/closing-issues-using-keywords/))
   - [ ] I've updated the documentation if necessary
   


-- 
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 pull request #1220: fix(requirements check): use regex to get java version from javac output

Posted by GitBox <gi...@apache.org>.
breautek commented on pull request #1220:
URL: https://github.com/apache/cordova-android/pull/1220#issuecomment-826815377


   > I also tried removing _JAVA_OPTIONS from the version check by adding env: {}, extendEnv: false to the options of the javac command like suggested here:
   
   Yah I don't think we can remove the environment variables, as that may contain details like `JAVA_HOME` used to point to the direction where Cordova should look for a path... otherwise it will find the first java variable in your path and call it a day which may not be what we want. ;)
   
   


-- 
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 pull request #1220: fix(requirements check): use regex to get java version from javac output

Posted by GitBox <gi...@apache.org>.
breautek commented on pull request #1220:
URL: https://github.com/apache/cordova-android/pull/1220#issuecomment-835608379


   Will merge by tomorrow night if there are no objections.


-- 
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 merged pull request #1220: fix(requirements check): use regex to get java version from javac output

Posted by GitBox <gi...@apache.org>.
breautek merged pull request #1220:
URL: https://github.com/apache/cordova-android/pull/1220


   


-- 
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 pull request #1220: fix(requirements check): use regex to get java version from javac output

Posted by GitBox <gi...@apache.org>.
breautek commented on pull request #1220:
URL: https://github.com/apache/cordova-android/pull/1220#issuecomment-835798290


   Thanks for the review @PieterVanPoyer and thank you for your contribution @DavidStrausz 


-- 
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