-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: java checks / get java version #1130
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really want the name of the file as Java.js
and not java.js
? I believe in almost every repo our filenames are lowercased.
Since this is introducing a new coding style, I think you should document when to use uppercase vs. lowercase and put a document somewhere like the cordova-contribute so we can understand these new cases.
We actually have quite a few modules with non-lowercase filenames in this repo that exactly match the exported class' name: That being said, if we change this module from a class to a plain object, |
Codecov Report
@@ Coverage Diff @@
## master #1130 +/- ##
==========================================
+ Coverage 71.80% 73.27% +1.46%
==========================================
Files 21 22 +1
Lines 1745 1766 +21
==========================================
+ Hits 1253 1294 +41
+ Misses 492 472 -20
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great to see improvements to the check_reqs
module! Especially the separation of environment checking and inference is something I thought should have been done for a long time.
I made a quick pass over the code, left a few comments and pushed a fix for one of the new tests. Overall, this looks quite good to me. I hope I can take a closer look at it soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added some more comments. I hope I didn't go overboard 😅
Coding habits from my own projects. I can convert this into a simple JS object and move the file to an I would want to keep the module exporting an object containing methods though as this makes it easy to unit test/spy functions without the use of rewire, and I personally want to try to limit the use of rewire as much as possible since it's not a package that is actually maintained. |
b5161a2
to
a5a6eec
Compare
14975fd
to
70bd062
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR looks pretty good to me 👍
My suggestions and comments are mainly cosmetic. Feel free to implement or discard those as you see fit.
The few non-cosmetic remarks are not a deal breaker either for me. So if there's no time to address them, that's fine with me too.
Sorry for taking so long with the review but I'm pretty swamped with work currently.
70bd062
to
be9588d
Compare
Co-authored-by: エリス <[email protected]> Co-authored-by: Raphael von der Grün <[email protected]> Update spec/unit/java.spec.js Co-authored-by: Raphael von der Grün <[email protected]> Update spec/unit/java.spec.js Co-authored-by: Raphael von der Grün <[email protected]> Update bin/templates/cordova/lib/utils.js Co-authored-by: Raphael von der Grün <[email protected]> Update bin/templates/cordova/lib/check_reqs.js Co-authored-by: Raphael von der Grün <[email protected]> Update spec/unit/check_reqs.spec.js Co-authored-by: Raphael von der Grün <[email protected]> Update spec/unit/check_reqs.spec.js Co-authored-by: Raphael von der Grün <[email protected]>
a7cecba
to
17dbc1d
Compare
Finally got around into finishing this up, I believe this could be incorporated into 9.1.x release, or do you think it should wait until 10.x? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, I think this can be released with the 9.1.0 minor release.
Hi @breautek, I hope it's okay if I add this here, but I can also open a new issue if you need one. For reference in my case I set them in export _JAVA_OPTIONS="-Xms2048M -Xmx4096M" And this is the exact error: Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=/Users/username/Library/Android/sdk (recommended setting)
ANDROID_HOME=undefined (DEPRECATED)
Requirements check failed for JDK 1.8.x! Detected version: 2048.0.0
Check your ANDROID_SDK_ROOT / JAVA_HOME / PATH environment variables. The reason for this is happening is because in the new implementation you are using Picked up _JAVA_OPTIONS: -Xms2048M -Xmx4096M
javac 1.8.0_271 The result is directly checked via semver without sanitizing the output first. In the old implementation a regular expression was used to only check the relevant parts: const match = /javac\s+([\d.]+)/i.exec(output); |
@DavidStrausz thanks for letting us know. Would you care to try if this problem can be resolved by adding the options If so, we surely would appreciate a pull request with that change. |
@raphinesse Thanks for your response! Interesting, didn't think of that way of fixing it yet, I will take a look sometime next week and will open a PR if this indeed resolves the issue! |
Co-authored-by: エリス <[email protected]> Co-authored-by: Raphael von der Grün <[email protected]> Update spec/unit/java.spec.js Co-authored-by: Raphael von der Grün <[email protected]> Update spec/unit/java.spec.js Co-authored-by: Raphael von der Grün <[email protected]> Update bin/templates/cordova/lib/utils.js Co-authored-by: Raphael von der Grün <[email protected]> Update bin/templates/cordova/lib/check_reqs.js Co-authored-by: Raphael von der Grün <[email protected]> Update spec/unit/check_reqs.spec.js Co-authored-by: Raphael von der Grün <[email protected]> Update spec/unit/check_reqs.spec.js Co-authored-by: Raphael von der Grün <[email protected]> Co-authored-by: Raphael von der Grün <[email protected]>
Platforms affected
Android
Motivation and Context
Prerequisite PR for #1060
This PR abstracts the Java checks and java version retrieval so that it can be reused.
Description
Created a new Java class with static methods that provides an API to get the version. It also contains the code that finds the java executable that used to live inside
check_reqs
.Java.js
is contains 100% line coverage, which is an upgrade from when the code lived incheck_reqs
.Testing
npm test
Checklist
(platform)
if this change only applies to one platform (e.g.(android)
)