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: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
