Skip to content
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

feat: CORDOVA_JAVA_HOME env variable #1229

Merged
merged 3 commits into from May 9, 2021

Conversation

breautek
Copy link
Contributor

@breautek breautek commented May 9, 2021

Platforms affected

Android

Motivation and Context

It's been a requested feature (not formally, but in variety of bug tickets of people trying to use java >8) because often times, we are stuck on using older Java versions
due to the Android SDK. This will make it easier for users to have multiple java versions installed.

Description

If CORDOVA_JAVA_HOME is present, it will override JAVA_HOME environment variable for the execution context of Cordova.

Testing

Unit test added. All existing tests passes. Manual testing.

Checklist

  • I've run the tests to see all new and existing tests pass
  • 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))
  • 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)
  • I've updated the documentation if necessary

@breautek breautek added this to the 10.0.0 milestone May 9, 2021
@codecov-commenter
Copy link

codecov-commenter commented May 9, 2021

Codecov Report

Merging #1229 (21d91fc) into master (1b78746) will increase coverage by 0.06%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1229      +/-   ##
==========================================
+ Coverage   71.95%   72.02%   +0.06%     
==========================================
  Files          21       21              
  Lines        1694     1698       +4     
==========================================
+ Hits         1219     1223       +4     
  Misses        475      475              
Impacted Files Coverage Δ
bin/templates/cordova/lib/env/java.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1b78746...21d91fc. Read the comment docs.

Copy link
Contributor

@PieterVanPoyer PieterVanPoyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a comment, but it is nitpicking, so feel free to look at it, and address it, ignore it, or give your opinion about my comment.

Minor, and discussable off course.

spec/unit/java.spec.js Outdated Show resolved Hide resolved
Copy link
Contributor

@PieterVanPoyer PieterVanPoyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome stuff!

@breautek
Copy link
Contributor Author

breautek commented May 9, 2021

Thanks for the review @PieterVanPoyer

Just going to push a new commit to fix the test faliure that occurs windows (stupid path separator differences....)

@breautek breautek merged commit ae4dba2 into apache:master May 9, 2021
@breautek breautek deleted the feat/cordova-java-home branch May 9, 2021 20:02
@breautek breautek added this to In Progress in Release Plan - 10.1.0 via automation May 9, 2021
breautek added a commit to breautek/cordova-android that referenced this pull request May 9, 2021
* feat: CORDOVA_JAVA_HOME env variable

* refactor: Improve CORDOVA_JAVA_HOME env test

* fix(test) path separator issue
@erisu erisu moved this from In Progress to Done in Release Plan - 10.1.0 Jul 14, 2021
wedgberto pushed a commit to wedgberto/cordova-android that referenced this pull request May 17, 2022
* feat: CORDOVA_JAVA_HOME env variable

* refactor: Improve CORDOVA_JAVA_HOME env test

* fix(test) path separator issue
@paulwwisl
Copy link

paulwwisl commented Apr 3, 2023

As of cordova 11.1 CORDOVA_JAVA_HOME is silently being used over JAVA_HOME

$ cordova --version
11.1.0
MBP:cordovaapp1$ cordova requirements

Requirements check results for android:
Java JDK: installed 11.0.15
Android SDK: installed true
Android target: installed android-33-ext5,android-33,android-32,android-31,android-30
Gradle: installed /opt/homebrew/Cellar/gradle/8.0.2/bin/gradle


ANDROID_HOME=/Users/pverest/Library/Android/sdk
ANDROID_SDK_ROOT=/Users/pverest/Library/Android/sdk
CORDOVA_JAVA_HOME=/Applications/Android Studio.app/Contents/jbr/Contents/Home
...
JAVA_HOME=/Users/pverest/Library/Java/JavaVirtualMachines/corretto-17.0.6-1/Contents/Home

i.e. for my setup jdk11 is used for cordova instead of jdk17 default in JAVA_HOME and on PATH

@breautek
Copy link
Contributor Author

breautek commented Apr 3, 2023

Thanks for pointing this out, I created an issue as a self reminder in our docs repo: apache/cordova-docs#1292

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants