erisu opened a new pull request, #1795:
URL: https://github.com/apache/cordova-android/pull/1795

   <!--
   Please make sure the checklist boxes are all checked before submitting the 
PR. The checklist is intended as a quick reference, for complete details please 
see our Contributor Guidelines:
   
   http://cordova.apache.org/contribute/contribute_guidelines.html
   
   Thanks!
   -->
   
   ### Motivation, Context & Description
   <!-- Why is this change required? What problem does it solve? -->
   <!-- If it fixes an open issue, please link to the issue here. -->
   
   Fix an issue mentioned in a [discussion 
thread](https://github.com/apache/cordova/discussions/530#discussioncomment-12605698).
   
   1. Ensure that Cordova-Android properly creates `config.properties`.
   2. Ensure that `java.home` is set correctly:
      1. Check and use the `CORDOVA_JAVA_HOME` environment variable.
      2. If `CORDOVA_JAVA_HOME` is missing, fall back to `JAVA_HOME`.
      3. If neither is set, remove the `java.home` property (if previously 
set), allowing Android Studio to display a warning and configure its internal 
Java automatically.
   3. Copy the `tools/.gradle` directory up one level.
   
   **Note:** Step 2.3 should not occur under normal conditions, but was 
included as a safeguard. When running `cordova build`, if `JAVA_HOME` is 
missing, its expected that the build stops.
   
   This change also ensures that Cordova-Android uses the correct Java version 
specified by the user via environment variables. According to the Cordova 
documentation, these variables must be configured for Cordova-Android setup. 
Defaulting to Android Studio's bundled Java could lead to unexpected results 
and not using versions that the App developer configured.
   
   ### Testing
   <!-- Please describe in detail how you tested your changes. -->
   
   - Create project
   - Add cordova-android platform with changes
   - Build for Android
   
   1. Use Case 1.a
   
   Confirm that `java.home` is set with configured environment variables.
   
   2. Use Case 1.b
   
   Re-run build with `CORDOVA_JAVA_HOME` set to another version of Java and 
confirm the `java.home` was updated.
   
   3. Use Case 2
   
   Created a `before_build` hookscript to before running `cordova build` for 
the first time.
   
   Confirm that the content of the hookscript was injected into the 
`config.properties` and that `java.home` was set correctly by the build script.
   
   ### Checklist
   
   - [x] 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](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.

To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org

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


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

Reply via email to