You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "erisu (via GitHub)" <gi...@apache.org> on 2025/02/19 05:45:06 UTC
[PR] feat: move gradle wrapper from tools to platform root dir [cordova-android]
erisu opened a new pull request, #1781:
URL: https://github.com/apache/cordova-android/pull/1781
<!--
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 and Context
<!-- Why is this change required? What problem does it solve? -->
<!-- If it fixes an open issue, please link to the issue here. -->
Move the gradle wrapper file creation from `platforms/android/tools` to `platforms/android`
Fixes #1760
### Description
<!-- Describe your changes in detail -->
- Updated nodejs side to make sure path removed `tools`.
- removed `tools/settings.gradle`. Appears not needed.
### Testing
<!-- Please describe in detail how you tested your changes. -->
- Created a Cordova Project
- Added Platform
- Built Android Platform
- Verified that the gradle-wrapper files were created in `platforms/android`
- Verified that the Project Structure settings in AS showed a Gradle version.
- Verified that the build tools in AS settings had found the wrapper's `gradle-wrapper.properties`
### 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)`)
- [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/))
- [x] 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-unsubscribe@cordova.apache.org
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
Re: [PR] fix: move gradle wrapper from tools to platform root dir [cordova-android]
Posted by "breautek (via GitHub)" <gi...@apache.org>.
breautek commented on PR #1781:
URL: https://github.com/apache/cordova-android/pull/1781#issuecomment-2669846779
> removed tools/settings.gradle. Appears not needed.
It will be needed if the installed gradle at the system level is less than what AGP requires. That was the whole point of adding it, to serve as a dummy project with no dependencies so that we can get our gradle wrapper.
--
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-unsubscribe@cordova.apache.org
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
Re: [PR] fix: move gradle wrapper from tools to platform root dir [cordova-android]
Posted by "breautek (via GitHub)" <gi...@apache.org>.
breautek commented on PR #1781:
URL: https://github.com/apache/cordova-android/pull/1781#issuecomment-2669876360
To solve https://github.com/apache/cordova-android/issues/1760
I think what we should do is copy the generated `gradle`, `gradlew`, and `gradlew.bat` files up a directory on each gradle wrapper install into `platforms/android/`. If the wrapper files already exists, then it should be replaced. We could also experiment with creating a symlink to `tools/gradlew`, `tools/gradle`, and `tools/gradlew.bat` (but idk if Android Studio will follow symlinks or if that will play nicely on windows)
We should also retain the tools/ gradle wrapper copy for future install commands. Like I mentioned, the `tools/` project is a dummy project with no dependencies, so it allows for the user to have a wide range of system gradle installed. On each build, the install command is issued, but if the wrapper is already installed at the desired version, it's nearly a no-operation, so it will help subsequent builds as well.
Android Studio will use the wrapper installed at `platforms/android/`. The CLI could continue to use the wrapper in `platforms/android/tools/` or be updated to use the copied version at `platforms/android`, that's up to preference at this point. But the CLI should make sure that `platforms/android/` gradle install is identical to the one inside `platform/android/tools/`.
I hope this makes sense. I know having a copy is not ideal, but it helps give us the best of both worlds:
1. Virtually any Gradle version can be used to install the gradle wrapper of the version needed by Cordova.
2. Installed gradle wrapper will be used by Android Studio if the project is opened in the IDE.
If the symlink idea works, then that could be use to reduce the maintenance burden as well.
--
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-unsubscribe@cordova.apache.org
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
Re: [PR] fix: move gradle wrapper from tools to platform root dir [cordova-android]
Posted by "erisu (via GitHub)" <gi...@apache.org>.
erisu commented on PR #1781:
URL: https://github.com/apache/cordova-android/pull/1781#issuecomment-2728463739
> we should do is copy the generated gradle, gradlew, and gradlew.bat files up a directory on each gradle wrapper install into platforms/android/.
This PR now copy up a directory as suggested.
> If the wrapper files already exists, then it should be replaced.
This should be complete. It always runs a copy with recursive+force on build.
> experiment with creating a symlink
Symlink will not be used because we need to ensure that the files remain when the platforms directory are zipped. It seems that there is a use case to prepare the platforms in one environment and built in another.
> We should also retain the tools/ gradle wrapper copy for future install commands.
Done
> Android Studio will use the wrapper installed at platforms/android/. The CLI could continue to use the wrapper in platforms/android/tools/
CLI uses tools version.
> CLI should make sure that platforms/android/ gradle install is identical to the one inside platform/android/tools/
CLI should always call the install gradle wrapper method and copy step during build. This would handle the case if users changes the version by preference.
This PR does not, and will not, cover the cases if the users upgrades from android studio. CLI build will undo those changes and replace grade back with tools version.
This PR will not cover creating of the gradle wrapper on `platform add`.
--
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-unsubscribe@cordova.apache.org
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
Re: [PR] feat: move gradle wrapper from tools to platform root dir [cordova-android]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #1781:
URL: https://github.com/apache/cordova-android/pull/1781#issuecomment-2667569775
## [Codecov](https://app.codecov.io/gh/apache/cordova-android/pull/1781?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 72.41%. Comparing base [(`8f458b0`)](https://app.codecov.io/gh/apache/cordova-android/commit/8f458b042bd61a779eec19516a9ec51e38e56c5e?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to head [(`c1fb457`)](https://app.codecov.io/gh/apache/cordova-android/commit/c1fb457ac4e7b77999c7d9d5adb4a45f42f9a086?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #1781 +/- ##
==========================================
- Coverage 72.50% 72.41% -0.10%
==========================================
Files 23 23
Lines 1837 1834 -3
==========================================
- Hits 1332 1328 -4
- Misses 505 506 +1
```
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/cordova-android/pull/1781?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
--
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-unsubscribe@cordova.apache.org
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
Re: [PR] fix: copy gradle wrapper from tools to platform root dir [cordova-android]
Posted by "erisu (via GitHub)" <gi...@apache.org>.
erisu merged PR #1781:
URL: https://github.com/apache/cordova-android/pull/1781
--
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-unsubscribe@cordova.apache.org
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
Re: [PR] fix: move gradle wrapper from tools to platform root dir [cordova-android]
Posted by "breautek (via GitHub)" <gi...@apache.org>.
breautek commented on PR #1781:
URL: https://github.com/apache/cordova-android/pull/1781#issuecomment-2669908003
This is kind of out of scope for https://github.com/apache/cordova-android/issues/1760 but I also notice that we don't install the wrapper on create. I think it may only occur on build.
We should also consider doing a gradle install on project creation too (on `cordova platform add android`) so that the wrapper is immediately available. We should still continue to install on build as well in case they change the gradle version preference...
As it stands right now, the wrapper is only installed on `cordova build android` which means if someone added the android platform and then opened it up in Android Studio, it won't have the expected wrapper version, until they run a `cordova build android`
Just something I noticed while testing the current behaviour.
--
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-unsubscribe@cordova.apache.org
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