You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "breautek (via GitHub)" <gi...@apache.org> on 2023/04/21 18:59:42 UTC
[GitHub] [cordova-android] breautek opened a new pull request, #1606: fix: Gradle Args parsing
breautek opened a new pull request, #1606:
URL: https://github.com/apache/cordova-android/pull/1606
<!--
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!
-->
### Platforms affected
Android / Gradle Argument pass through
### 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. -->
gradle expects a specific usage which Cordova doesn't conform to.
```
$ gradle --help
USAGE: gradle [option...] [task...]
```
Currently we append the gradle arguments at the end of the gradle argument list, but option arguments are suppose to appear before the task(s).
Closes https://github.com/apache/cordova-android/issues/1604
Additionally, while testing I also discovered that arguments that requires multiple values (e.g. `--warning-mode all`) doesn't get passed through properly, yielding an argument array that looks like:
```javascript
[ "--warning-mode all" ]
````
when the expect array should look like:
```javascript
[ "--warning-mode", "all" ]
```
### Description
<!-- Describe your changes in detail -->
- Re-ordered the gradle argument array creation so that options appears before the task.
- Corrected tests who assumed the task will appear at index 0. Tasks will always appear at the end of the array now and have been updated accordingly with that specific expectation.
- Added a dependency to [string-argv](https://www.npmjs.com/package/string-argv). `nopt` does not fit here because it expects that you know what your CLI arguments are. However since these arguments are gradle arguments, it's better if we can parse them and pass them through. This package handles quotations and such to ensure a proper argv array is created.
### Testing
<!-- Please describe in detail how you tested your changes. -->
Ran `npm test` and manually tested in hello world app using commands such as:
`cordova build android --minSdkVersion 30 -- --gradleArg="--stacktrace"`
`cordova build android --minSdkVersion 30 -- --gradleArg="--stacktrace --warning-mode all"`
### 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
- [x] 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
[GitHub] [cordova-android] erisu commented on a diff in pull request #1606: fix: Gradle Args parsing
Posted by "erisu (via GitHub)" <gi...@apache.org>.
erisu commented on code in PR #1606:
URL: https://github.com/apache/cordova-android/pull/1606#discussion_r1174349278
##########
lib/build.js:
##########
@@ -58,7 +63,8 @@ function parseOpts (options, resolvedTarget, projectRoot) {
if (options.argv.maxSdkVersion) { ret.extraArgs.push('-PcdvMaxSdkVersion=' + options.argv.maxSdkVersion); }
if (options.argv.targetSdkVersion) { ret.extraArgs.push('-PcdvTargetSdkVersion=' + options.argv.targetSdkVersion); }
if (options.argv.gradleArg) {
- ret.extraArgs = ret.extraArgs.concat(options.argv.gradleArg);
+ const gradleArgs = ARGVParser.parseArgsStringToArgv(options.argv.gradleArg[0]);
Review Comment:
```suggestion
const gradleArgs = parseArgsStringToArgv(options.argv.gradleArg[0]);
```
##########
lib/build.js:
##########
@@ -21,6 +21,7 @@ const path = require('path');
const fs = require('fs');
const nopt = require('nopt');
const untildify = require('untildify');
+const ARGVParser = require('string-argv');
Review Comment:
```suggestion
const { parseArgsStringToArgv } = require('string-argv');
```
--
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
[GitHub] [cordova-android] codecov-commenter commented on pull request #1606: fix: Gradle Args parsing
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #1606:
URL: https://github.com/apache/cordova-android/pull/1606#issuecomment-1518232237
## [Codecov](https://codecov.io/gh/apache/cordova-android/pull/1606?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#1606](https://codecov.io/gh/apache/cordova-android/pull/1606?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (0a1fd90) into [master](https://codecov.io/gh/apache/cordova-android/commit/2252c09a49f0e0ff6de40a7ceb988e61c330ffc7?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (2252c09) will **increase** coverage by `0.00%`.
> The diff coverage is `75.00%`.
```diff
@@ Coverage Diff @@
## master #1606 +/- ##
=======================================
Coverage 71.82% 71.83%
=======================================
Files 23 23
Lines 1796 1800 +4
=======================================
+ Hits 1290 1293 +3
- Misses 506 507 +1
```
| [Impacted Files](https://codecov.io/gh/apache/cordova-android/pull/1606?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [lib/build.js](https://codecov.io/gh/apache/cordova-android/pull/1606?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-bGliL2J1aWxkLmpz) | `40.77% <33.33%> (+0.18%)` | :arrow_up: |
| [lib/builders/ProjectBuilder.js](https://codecov.io/gh/apache/cordova-android/pull/1606?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-bGliL2J1aWxkZXJzL1Byb2plY3RCdWlsZGVyLmpz) | `70.00% <100.00%> (+0.37%)` | :arrow_up: |
:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
--
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
[GitHub] [cordova-android] breautek merged pull request #1606: fix: Gradle Args parsing
Posted by "breautek (via GitHub)" <gi...@apache.org>.
breautek merged PR #1606:
URL: https://github.com/apache/cordova-android/pull/1606
--
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
[GitHub] [cordova-android] breautek commented on pull request #1606: fix: Gradle Args parsing
Posted by "breautek (via GitHub)" <gi...@apache.org>.
breautek commented on PR #1606:
URL: https://github.com/apache/cordova-android/pull/1606#issuecomment-1518705716
> This looks okay to me.
>
> It would maybe be good to have a test case that covered the splitting of `gradleArgs` into multiple `extraArgs` tokens.
I added a new `build.spec.js` unit test file since gradle argument parsing happens earlier than what `ProjectBuilder.spec.js` tests. I only added testing that was relevant in the PR but could probably be expanded further to match more closely to what `run.spec.js` does.
Added series of different test cases regarding using the `--gradleArg` flag and testing the parsed argv array, which would include the usage of `nopt` + `string-argv` third-party dependencies.
--
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