Browse Source

Update to new android cordova build

Signed-off-by: Chris Cromer <chris@cromer.cl>
Chris Cromer 1 month ago
parent
commit
179caec389
100 changed files with 741 additions and 3397 deletions
  1. 0
    2
      config.xml
  2. 2
    1
      node_modules/cordova-android/.eslintignore
  3. 20
    7
      node_modules/cordova-android/.github/PULL_REQUEST_TEMPLATE.md
  4. 23
    14
      node_modules/cordova-android/.travis.yml
  5. 0
    1
      node_modules/cordova-android/CONTRIBUTING.md
  6. 0
    3
      node_modules/cordova-android/README.md
  7. 51
    30
      node_modules/cordova-android/RELEASENOTES.md
  8. 1
    1
      node_modules/cordova-android/VERSION
  9. 29
    31
      node_modules/cordova-android/appveyor.yml
  10. 1
    3
      node_modules/cordova-android/bin/android_sdk_version
  11. 3
    2
      node_modules/cordova-android/bin/check_reqs
  12. 6
    6
      node_modules/cordova-android/bin/create
  13. 7
    4
      node_modules/cordova-android/bin/lib/create.js
  14. 19
    60
      node_modules/cordova-android/bin/templates/cordova/Api.js
  15. 13
    12
      node_modules/cordova-android/bin/templates/cordova/build
  16. 9
    9
      node_modules/cordova-android/bin/templates/cordova/clean
  17. 4
    4
      node_modules/cordova-android/bin/templates/cordova/lib/Adb.js
  18. 1
    5
      node_modules/cordova-android/bin/templates/cordova/lib/AndroidManifest.js
  19. 2
    9
      node_modules/cordova-android/bin/templates/cordova/lib/AndroidProject.js
  20. 0
    11
      node_modules/cordova-android/bin/templates/cordova/lib/AndroidStudio.js
  21. 1
    2
      node_modules/cordova-android/bin/templates/cordova/lib/android_sdk.js
  22. 8
    24
      node_modules/cordova-android/bin/templates/cordova/lib/build.js
  23. 0
    124
      node_modules/cordova-android/bin/templates/cordova/lib/builders/GenericBuilder.js
  24. 0
    331
      node_modules/cordova-android/bin/templates/cordova/lib/builders/GradleBuilder.js
  25. 0
    303
      node_modules/cordova-android/bin/templates/cordova/lib/builders/StudioBuilder.js
  26. 21
    33
      node_modules/cordova-android/bin/templates/cordova/lib/builders/builders.js
  27. 21
    9
      node_modules/cordova-android/bin/templates/cordova/lib/check_reqs.js
  28. 5
    6
      node_modules/cordova-android/bin/templates/cordova/lib/device.js
  29. 28
    32
      node_modules/cordova-android/bin/templates/cordova/lib/emulator.js
  30. 8
    8
      node_modules/cordova-android/bin/templates/cordova/lib/install-device
  31. 7
    7
      node_modules/cordova-android/bin/templates/cordova/lib/install-emulator
  32. 4
    4
      node_modules/cordova-android/bin/templates/cordova/lib/list-devices
  33. 4
    4
      node_modules/cordova-android/bin/templates/cordova/lib/list-emulator-images
  34. 4
    4
      node_modules/cordova-android/bin/templates/cordova/lib/list-started-emulators
  35. 1
    1
      node_modules/cordova-android/bin/templates/cordova/lib/log.js
  36. 2
    5
      node_modules/cordova-android/bin/templates/cordova/lib/plugin-build.gradle
  37. 33
    44
      node_modules/cordova-android/bin/templates/cordova/lib/pluginHandlers.js
  38. 255
    34
      node_modules/cordova-android/bin/templates/cordova/lib/prepare.js
  39. 8
    12
      node_modules/cordova-android/bin/templates/cordova/lib/retry.js
  40. 7
    8
      node_modules/cordova-android/bin/templates/cordova/lib/run.js
  41. 7
    8
      node_modules/cordova-android/bin/templates/cordova/lib/start-emulator
  42. 6
    6
      node_modules/cordova-android/bin/templates/cordova/log
  43. 15
    14
      node_modules/cordova-android/bin/templates/cordova/run
  44. 1
    1
      node_modules/cordova-android/bin/templates/cordova/version
  45. 1
    1
      node_modules/cordova-android/bin/templates/project/AndroidManifest.xml
  46. 21
    20
      node_modules/cordova-android/bin/templates/project/app/build.gradle
  47. 8
    289
      node_modules/cordova-android/bin/templates/project/assets/www/cordova.js
  48. 9
    11
      node_modules/cordova-android/bin/templates/project/build.gradle
  49. 8
    1
      node_modules/cordova-android/bin/templates/project/gitignore
  50. 1
    1
      node_modules/cordova-android/bin/templates/project/legacy/build.gradle
  51. BIN
      node_modules/cordova-android/bin/templates/project/res/mipmap-hdpi/icon.png
  52. BIN
      node_modules/cordova-android/bin/templates/project/res/mipmap-ldpi/icon.png
  53. BIN
      node_modules/cordova-android/bin/templates/project/res/mipmap-mdpi/icon.png
  54. BIN
      node_modules/cordova-android/bin/templates/project/res/mipmap-xhdpi/icon.png
  55. BIN
      node_modules/cordova-android/bin/templates/project/res/mipmap-xxhdpi/icon.png
  56. BIN
      node_modules/cordova-android/bin/templates/project/res/mipmap-xxxhdpi/icon.png
  57. 4
    4
      node_modules/cordova-android/bin/update
  58. 13
    14
      node_modules/cordova-android/framework/build.gradle
  59. 1
    1
      node_modules/cordova-android/framework/gradle/wrapper/gradle-wrapper.properties
  60. 4
    9
      node_modules/cordova-android/framework/project.properties
  61. 1
    1
      node_modules/cordova-android/framework/src/org/apache/cordova/CordovaWebView.java
  62. 2
    0
      node_modules/cordova-android/framework/src/org/apache/cordova/CordovaWebViewImpl.java
  63. 19
    2
      node_modules/cordova-android/framework/src/org/apache/cordova/CoreAndroid.java
  64. 5
    1
      node_modules/cordova-android/framework/src/org/apache/cordova/engine/SystemCookieManager.java
  65. 3
    0
      node_modules/cordova-android/framework/src/org/apache/cordova/engine/SystemWebChromeClient.java
  66. 4
    1
      node_modules/cordova-android/framework/src/org/apache/cordova/engine/SystemWebViewClient.java
  67. 0
    1
      node_modules/cordova-android/node_modules/.bin/nopt
  68. 0
    1
      node_modules/cordova-android/node_modules/.bin/semver
  69. 0
    1
      node_modules/cordova-android/node_modules/.bin/shjs
  70. 0
    46
      node_modules/cordova-android/node_modules/abbrev/LICENSE
  71. 0
    23
      node_modules/cordova-android/node_modules/abbrev/README.md
  72. 0
    61
      node_modules/cordova-android/node_modules/abbrev/abbrev.js
  73. 0
    57
      node_modules/cordova-android/node_modules/abbrev/package.json
  74. 0
    8
      node_modules/cordova-android/node_modules/android-versions/.jshintignore
  75. 0
    29
      node_modules/cordova-android/node_modules/android-versions/.jshintrc
  76. 0
    3
      node_modules/cordova-android/node_modules/android-versions/.travis.yml
  77. 0
    87
      node_modules/cordova-android/node_modules/android-versions/README.md
  78. 0
    161
      node_modules/cordova-android/node_modules/android-versions/index.js
  79. 0
    67
      node_modules/cordova-android/node_modules/android-versions/package.json
  80. 0
    118
      node_modules/cordova-android/node_modules/android-versions/tests/index.test.js
  81. 0
    4
      node_modules/cordova-android/node_modules/ansi/.jshintrc
  82. 0
    1
      node_modules/cordova-android/node_modules/ansi/.npmignore
  83. 0
    23
      node_modules/cordova-android/node_modules/ansi/History.md
  84. 0
    24
      node_modules/cordova-android/node_modules/ansi/LICENSE
  85. 0
    98
      node_modules/cordova-android/node_modules/ansi/README.md
  86. 0
    16
      node_modules/cordova-android/node_modules/ansi/examples/beep/index.js
  87. 0
    15
      node_modules/cordova-android/node_modules/ansi/examples/clear/index.js
  88. 0
    32
      node_modules/cordova-android/node_modules/ansi/examples/cursorPosition.js
  89. 0
    87
      node_modules/cordova-android/node_modules/ansi/examples/progress/index.js
  90. 0
    405
      node_modules/cordova-android/node_modules/ansi/lib/ansi.js
  91. 0
    71
      node_modules/cordova-android/node_modules/ansi/lib/newlines.js
  92. 0
    56
      node_modules/cordova-android/node_modules/ansi/package.json
  93. 0
    5
      node_modules/cordova-android/node_modules/balanced-match/.npmignore
  94. 0
    21
      node_modules/cordova-android/node_modules/balanced-match/LICENSE.md
  95. 0
    91
      node_modules/cordova-android/node_modules/balanced-match/README.md
  96. 0
    59
      node_modules/cordova-android/node_modules/balanced-match/index.js
  97. 0
    78
      node_modules/cordova-android/node_modules/balanced-match/package.json
  98. 0
    21
      node_modules/cordova-android/node_modules/base64-js/LICENSE
  99. 0
    32
      node_modules/cordova-android/node_modules/base64-js/README.md
  100. 0
    0
      node_modules/cordova-android/node_modules/base64-js/base64js.min.js

+ 0
- 2
config.xml View File

@@ -36,6 +36,4 @@
36 36
         <allow-intent href="itms-apps:*" />
37 37
     </platform>
38 38
     <plugin name="cordova-plugin-splashscreen" spec="^5.0.2" />
39
-    <engine name="browser" spec="^5.0.4" />
40
-    <engine name="android" spec="^7.1.4" />
41 39
 </widget>

+ 2
- 1
node_modules/cordova-android/.eslintignore View File

@@ -1 +1,2 @@
1
-bin/templates/project/assets/www/cordova.js
1
+bin/templates/project/assets/www/cordova.js
2
+test/app

+ 20
- 7
node_modules/cordova-android/.github/PULL_REQUEST_TEMPLATE.md View File

@@ -1,6 +1,5 @@
1 1
 <!--
2
-Please make sure the checklist boxes are all checked before submitting the PR. The checklist
3
-is intended as a quick reference, for complete details please see our Contributor Guidelines:
2
+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:
4 3
 
5 4
 http://cordova.apache.org/contribute/contribute_guidelines.html
6 5
 
@@ -10,13 +9,27 @@ Thanks!
10 9
 ### Platforms affected
11 10
 
12 11
 
13
-### What does this PR do?
14 12
 
13
+### Motivation and Context
14
+<!-- Why is this change required? What problem does it solve? -->
15
+<!-- If it fixes an open issue, please link to the issue here. -->
16
+
17
+
18
+
19
+### Description
20
+<!-- Describe your changes in detail -->
21
+
22
+
23
+
24
+### Testing
25
+<!-- Please describe in detail how you tested your changes. -->
15 26
 
16
-### What testing has been done on this change?
17 27
 
18 28
 
19 29
 ### Checklist
20
-- [ ] [Reported an issue](http://cordova.apache.org/contribute/issues.html) in the JIRA database
21
-- [ ] Commit message follows the format: "CB-3232: (android) Fix bug with resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform affected.
22
-- [ ] Added automated test coverage as appropriate for this change.
30
+
31
+- [ ] I've run the tests to see all new and existing tests pass
32
+- [ ] I added automated test coverage as appropriate for this change
33
+- [ ] Commit is prefixed with `(platform)` if this change only applies to one platform (e.g. `(android)`)
34
+- [ ] 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/))
35
+- [ ] I've updated the documentation if necessary

+ 23
- 14
node_modules/cordova-android/.travis.yml View File

@@ -2,27 +2,36 @@ language: android
2 2
 sudo: false
3 3
 jdk:
4 4
     - oraclejdk8
5
-env:
6
-    global:
7
-      - ANDROID_TOOLS=${ANDROID_HOME}/tools
8
-before_install:
9
-    - nvm install 6
10
-    # ensure at least gradle 3.3 is in place.
11
-    - wget http://services.gradle.org/distributions/gradle-3.3-bin.zip
12
-    - unzip gradle-3.3-bin.zip
13
-    - export GRADLE_HOME=$PWD/gradle-3.3
14
-    - export PATH=${GRADLE_HOME}/bin:${ANDROID_HOME}:${ANDROID_HOME}/emulator:${ANDROID_TOOLS}:${ANDROID_TOOLS}/bin:${ANDROID_HOME}/platform-tools:$PATH
15
-    - node --version
16
-    - gradle --version
17
-    - echo y | android --silent update sdk --no-ui --all --filter platform-tools,tools,build-tools-26.0.2,android-26,android-25,extra-google-m2repository,extra-android-m2repository
5
+
18 6
 android:
19 7
     components:
20
-      - tools
8
+        - build-tools-28.0.3
9
+env:
10
+    global:
11
+        # Keep gradle from crapping all over the log
12
+        - TERM=dumb
13
+    matrix:
14
+        - nodejs_version=6
15
+        - nodejs_version=8
16
+        - nodejs_version=10
17
+
21 18
 install:
19
+    # Install a sdkmanager version that supports the --licenses switch and
20
+    # accept any Android SDK licenses. The output redirection prevents us from
21
+    # hitting the travis log size limit of 4MB which would fail the build.
22
+    - yes | sdkmanager tools > /dev/null
23
+    - yes | sdkmanager --licenses > /dev/null
24
+
25
+    - nvm install $nodejs_version
22 26
     - npm install
23 27
     - npm install -g codecov
28
+
24 29
 script:
30
+    - gradle --version
31
+    - node --version
32
+    - npm --version
25 33
     - npm test
26 34
     - npm run cover
35
+
27 36
 after_script:
28 37
     - codecov

+ 0
- 1
node_modules/cordova-android/CONTRIBUTING.md View File

@@ -30,7 +30,6 @@ For instructions on this, start with the
30 30
 [contribution overview](http://cordova.apache.org/contribute/).
31 31
 
32 32
 The details are explained there, but the important items are:
33
- - Sign and submit an Apache ICLA (Contributor License Agreement).
34 33
  - Have a Jira issue open that corresponds to your contribution.
35 34
  - Run the tests so your patch doesn't break existing functionality.
36 35
 

+ 0
- 3
node_modules/cordova-android/README.md View File

@@ -31,9 +31,6 @@ at the core, applications written with web technology: HTML, CSS and JavaScript.
31 31
 
32 32
 [Apache Cordova](https://cordova.apache.org) is a project of The Apache Software Foundation (ASF).
33 33
 
34
-:warning: Report issues on the [Apache Cordova issue tracker](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Android%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC)
35
-
36
-
37 34
 ## Requires
38 35
 
39 36
 - Java JDK 1.8 or greater

+ 51
- 30
node_modules/cordova-android/RELEASENOTES.md View File

@@ -20,37 +20,58 @@
20 20
 -->
21 21
 ## Release Notes for Cordova (Android) ##
22 22
 
23
-### 7.1.4 (Nov 22, 2018)
24
-
25
-* Update android-versions to `1.4.0`, with added support for Android Pie ([#573](https://github.com/apache/cordova-android/pull/573))
26
-* Output current package name if package name can't be validated ([#567](https://github.com/apache/cordova-android/pull/567))
27
-* Resolve issue with plugin `target-dir="*app*"` subdirs ([#572](https://github.com/apache/cordova-android/pull/572))
28
-
29
-### 7.1.3 (Nov 19, 2018)
30
-
23
+### 8.0.0 (Feb 13, 2019)
24
+* [GH-669](https://github.com/apache/cordova-android/pull/669) Added Missing License Headers
25
+* [GH-655](https://github.com/apache/cordova-android/pull/655) Use custom Gradle properties to read minSdkVersion value from `config.xml`
26
+* [GH-656](https://github.com/apache/cordova-android/pull/656) Quick fix to support **Android**_SDK_ROOT
27
+* [GH-632](https://github.com/apache/cordova-android/pull/632) Ignore more Gradle build artifacts in **Android** project
28
+* [GH-642](https://github.com/apache/cordova-android/pull/642) **Android** tools 3.3 & **Gradle** 4.10.3 update
29
+* [GH-654](https://github.com/apache/cordova-android/pull/654) Quick updates to top-level `project.properties`
30
+* [GH-635](https://github.com/apache/cordova-android/pull/635) Ignore **Android** Studio `.idea` files in project
31
+* [GH-624](https://github.com/apache/cordova-android/pull/624) Add missing log to Java version check
32
+* [GH-630](https://github.com/apache/cordova-android/pull/630) Update `emulator.js` to fix issue [GH-608](https://github.com/apache/cordova-android/pull/608)
33
+* [GH-626](https://github.com/apache/cordova-android/pull/626) Added `package-lock.json` to `.gitignore`
34
+* [GH-620](https://github.com/apache/cordova-android/pull/620) Fix requirements error messages for JDK 8
35
+* [GH-619](https://github.com/apache/cordova-android/pull/619) javac error message fixes in requirements check
36
+* [GH-612](https://github.com/apache/cordova-android/pull/612) Android Platform Release Preparation (Cordova 9)
37
+* [GH-607](https://github.com/apache/cordova-android/pull/607) Copy `node_modules` if the directory exists
38
+* [GH-582](https://github.com/apache/cordova-android/pull/582) Improve Test `README`
39
+* [GH-589](https://github.com/apache/cordova-android/pull/589) Rewrite install dir resolution for legacy plugins
40
+* [GH-572](https://github.com/apache/cordova-android/pull/572) Resolve issue with plugin `target-dir="app*"` subdirs
41
+* [GH-567](https://github.com/apache/cordova-android/pull/567) Output current package name if package name can't be validated
42
+* [GH-507](https://github.com/apache/cordova-android/pull/507) Gradle Updates
43
+* [GH-559](https://github.com/apache/cordova-android/pull/559) Eslint ignore version file
44
+* [GH-550](https://github.com/apache/cordova-android/pull/550) Fix for old plugins with non-Java sources
45
+* [GH-558](https://github.com/apache/cordova-android/pull/558) Update `cordova.js` from `cordova-js@4.2.3`
46
+* [GH-553](https://github.com/apache/cordova-android/pull/553) Check for `build-extras.gradle` in the app-parent directory
47
+* [GH-551](https://github.com/apache/cordova-android/pull/551) Add missing cast for `cdvMinSdkVersion`
48
+* [GH-539](https://github.com/apache/cordova-android/pull/539) Fix destination path fallback
49
+* [GH-544](https://github.com/apache/cordova-android/pull/544) Remove obsolete check for JellyBean
50
+* [GH-465](https://github.com/apache/cordova-android/pull/465) Removes Gradle property in-line command arguments for `gradle.properties`
51
+* [GH-523](https://github.com/apache/cordova-android/pull/523) Always put the Google repo above jcenter
52
+* [GH-486](https://github.com/apache/cordova-android/pull/486) Change deprecated "compile" to "implementation"
31 53
 * [GH-495](https://github.com/apache/cordova-android/pull/495) Incorrect default sdk version issue fix
32
-* [GH-496](https://github.com/apache/cordova-android/pull/496) update comments in `build.gradle`
33
-* [GH-539](https://github.com/apache/cordova-android/pull/539) Fix dest overwrite, in case of of plugin `source-file` element with `target-dir` that does not need remapping
34
-* [GH-540](https://github.com/apache/cordova-android/issues/540) support plugin `source-file` element with any app `target-dir` value
35
-* [GH-547](https://github.com/apache/cordova-android/issues/547) Compatibility of old plugins with non-Java `source-file` entries (individual files)
36
-* [GH-551](https://github.com/apache/cordova-android/pull/551) add missing cast for cdvMinSdkVersion to `build.gradle`
37
-* [GH-552](https://github.com/apache/cordova-android/issues/552) check for `build-extras.gradle` in the parent app directory
38
-
39
-### 7.1.2 (Nov 08, 2018)
40
-* [CB-14127](https://issues.apache.org/jira/browse/CB-14127): Always put the Google repo above jcenter
41
-* [CB-14165](https://issues.apache.org/jira/browse/CB-14165): Emulator: handle "device still connecting" error (#457)
42
-* [CB-14125](https://issues.apache.org/jira/browse/CB-14125): Increase old plugin compatibility
43
-* [CB-13830](https://issues.apache.org/jira/browse/CB-13830): Add handlers for plugins that use non-Java source files, such as Camera
44
-* [CB-14038](https://issues.apache.org/jira/browse/CB-14038): fix false positive detecting project type
45
-
46
-### 7.1.1 (Jul 11, 2018)
47
-* Fix unsafe property access in run.js (#445)
48
-* Emit log event instead of logging directly (#452)
49
-* [CB-14101](https://issues.apache.org/jira/browse/CB-14101) Fix Java version check for Java >= 9 (#446)
50
-* [CB-14127](https://issues.apache.org/jira/browse/CB-14127) (android) Move google maven repo ahead of jcenter
51
-* [CB-13923](https://issues.apache.org/jira/browse/CB-13923) (android) fix -1 length for compressed files
52
-* [CB-14145](https://issues.apache.org/jira/browse/CB-14145) use cordova-common@2.2.5 and update other dependencies to resolve `npm audit` warnings
53
-* [CB-9366](https://issues.apache.org/jira/browse/CB-9366) log error.stack in cordova.js
54
+* [GH-493](https://github.com/apache/cordova-android/pull/493) Remove bundled dependencies
55
+* [GH-490](https://github.com/apache/cordova-android/pull/490) Fixes build & run related bugs from builder refactor
56
+* [GH-464](https://github.com/apache/cordova-android/pull/464) Unit tests for **Android**_sdk and **Android**Project
57
+* [GH-448](https://github.com/apache/cordova-android/pull/448) [CB-13685](https://issues.apache.org/jira/browse/CB-13685) Adaptive Icon Support
58
+* [GH-487](https://github.com/apache/cordova-android/pull/487) Do not attempt an activity intent AND a url load into the webview, return from the internal webview load.
59
+* [GH-461](https://github.com/apache/cordova-android/pull/461) Remove old builders code
60
+* [GH-463](https://github.com/apache/cordova-android/pull/463) Emulator: Add unit tests and remove Q
61
+* [GH-462](https://github.com/apache/cordova-android/pull/462) Device: Add unit tests and remove Q
62
+* [GH-457](https://github.com/apache/cordova-android/pull/457) Emulator: handle "device still connecting" error
63
+* [GH-445](https://github.com/apache/cordova-android/pull/445) Run and retryPromise improvements and tests
64
+* [GH-453](https://github.com/apache/cordova-android/pull/453) Lint JS files w/out extension too
65
+* [GH-452](https://github.com/apache/cordova-android/pull/452) Emit log event instead of logging directly
66
+* [GH-449](https://github.com/apache/cordova-android/pull/449) Increase old plugin compatibility
67
+* [GH-442](https://github.com/apache/cordova-android/pull/442) Fixes and cleanup for Java tests and CI
68
+* [GH-446](https://github.com/apache/cordova-android/pull/446) [CB-14101](https://issues.apache.org/jira/browse/CB-14101) Fix Java version check for Java >= 9
69
+* [CB-14127](https://issues.apache.org/jira/browse/CB-14127) Move google maven repo ahead of jcenter
70
+* [CB-14038](https://issues.apache.org/jira/browse/CB-14038) Fix false positive detecting project type
71
+* [CB-14008](https://issues.apache.org/jira/browse/CB-14008) Updating Gradle Libraries to work with **Android** Studio 3.1.0
72
+* [CB-13975](https://issues.apache.org/jira/browse/CB-13975) Fix to fire pause event when cdvStartInBackground=true
73
+* [CB-13830](https://issues.apache.org/jira/browse/CB-13830) Add handlers for plugins that use non-Java source files, such as Camera
74
+* [CB-13923](https://issues.apache.org/jira/browse/CB-13923) Fix -1 length for compressed files
54 75
 
55 76
 ### 7.1.0 (Feb 20, 2018)
56 77
 * [CB-13879](https://issues.apache.org/jira/browse/CB-13879) updated gradle tools dependency to 3.0.1 for project template

+ 1
- 1
node_modules/cordova-android/VERSION View File

@@ -1 +1 @@
1
-7.1.4
1
+8.0.0

+ 29
- 31
node_modules/cordova-android/appveyor.yml View File

@@ -1,38 +1,36 @@
1
-image:
2
-  - Previous Visual Studio 2015
3
-
4 1
 environment:
5
-  ANDROID_HOME: "C:\\android"
6
-  matrix:
7
-  - nodejs_version: "4"
8
-  - nodejs_version: "6"
9
-  - nodejs_version: "8"
10
-
11
-init:
12
-  - mkdir "%ANDROID_HOME%
13
-  - cd "%ANDROID_HOME%"
14
-  - appveyor DownloadFile "https://dl.google.com/android/repository/tools_r25.2.3-windows.zip"
15
-  - 7z x "tools_r25.2.3-windows.zip" > nul
16
-  - cd "C:\projects\cordova-android"
2
+    ANDROID_HOME: "C:\\android"
3
+
4
+    # If the gradle daemon is used, the build hangs after generating the wrapper
5
+    GRADLE_OPTS: -Dorg.gradle.daemon=false
6
+
7
+    # URL for SDK Tools, Revision 26.1.1 (September 2017)
8
+    SDK_TOOLS_URL: https://dl.google.com/android/repository/sdk-tools-windows-4333796.zip
9
+
10
+    matrix:
11
+        - nodejs_version: 6
12
+        - nodejs_version: 8
13
+        - nodejs_version: 10
17 14
 
18 15
 install:
19
-  - choco install gradle -version 3.4.1
20
-  - gradle -version
21
-  - echo y | "%ANDROID_HOME%\tools\android.bat" --silent update sdk --no-ui --all --filter platform-tools,tools,build-tools-26.0.2,android-26,android-25,extra-google-m2repository,extra-android-m2repository
22
-  # on windows we need to accept sublicenses for the new tooling, wee. 30 is an arbitrary number,
23
-  # but should be the maximum number of licenses we explicitly need to type "Y ENTER" for.
24
-  # also, the sdkmanager in all its glory leaks a bit of output to stderr, and powershell
25
-  # and appveyor interpret that as errors, and blows up. so, when piping in our "Y ENTER"
26
-  # responses, we invoke cmd so we can redirect stderr to stdout, and tell it to --update itself.
27
-  - ps: for($i=0;$i -lt 30;$i++) { $response += "y`n"}; $response | cmd /c 'C:\android\tools\bin\sdkmanager.bat 2>&1' --update
28
-  - ps: Install-Product node $env:nodejs_version
29
-  - npm install
30
-  # below is a workaround on using gradle installed via choco on appveyor
31
-  - set path=C:\ProgramData\chocolatey\lib\gradle\tools\gradle-3.4.1\bin;%path%
16
+    # Install Android SDK Tools
17
+    - mkdir "%ANDROID_HOME%"
18
+    - appveyor DownloadFile "%SDK_TOOLS_URL%" -FileName "%TMP%/sdk-tools.zip"
19
+    - 7z x "%TMP%/sdk-tools.zip" -o"%ANDROID_HOME%" > nul
20
+    - set PATH=%PATH%;"%ANDROID_HOME%\tools\bin"
21
+
22
+    - yes 2> nul | sdkmanager --licenses > nul
23
+    - sdkmanager "build-tools;28.0.3"
24
+
25
+    - choco install gradle --version 3.4.1
26
+
27
+    - ps: Install-Product node $env:nodejs_version
28
+    - npm install
32 29
 
33 30
 build: off
34 31
 
35 32
 test_script:
36
-  - node --version
37
-  - npm --version
38
-  - npm test
33
+    - gradle --version
34
+    - node --version
35
+    - npm --version
36
+    - npm test

+ 1
- 3
node_modules/cordova-android/bin/android_sdk_version View File

@@ -21,9 +21,7 @@
21 21
 
22 22
 var android_sdk = require('./templates/cordova/lib/android_sdk');
23 23
 
24
-android_sdk.print_newest_available_sdk_target().done(null, function(err) {
24
+android_sdk.print_newest_available_sdk_target().done(null, function (err) {
25 25
     console.error(err);
26 26
     process.exit(2);
27 27
 });
28
-
29
-

+ 3
- 2
node_modules/cordova-android/bin/check_reqs View File

@@ -22,9 +22,10 @@
22 22
 var check_reqs = require('./templates/cordova/lib/check_reqs');
23 23
 
24 24
 check_reqs.run().done(
25
-    function success() {
25
+    function success () {
26 26
         console.log('Looks like your environment fully supports cordova-android development!');
27
-    }, function fail(err) {
27
+    },
28
+    function fail (err) {
28 29
         console.log(err);
29 30
         process.exit(2);
30 31
     }

+ 6
- 6
node_modules/cordova-android/bin/create View File

@@ -23,12 +23,12 @@ var ConfigParser = require('cordova-common').ConfigParser;
23 23
 var Api = require('./templates/cordova/Api');
24 24
 
25 25
 var argv = require('nopt')({
26
-    'help' : Boolean,
27
-    'cli' : Boolean,
28
-    'shared' : Boolean,
29
-    'link' : Boolean,
30
-    'activity-name' : [String, undefined]
31
-}, { 'd' : '--verbose' });
26
+    'help': Boolean,
27
+    'cli': Boolean,
28
+    'shared': Boolean,
29
+    'link': Boolean,
30
+    'activity-name': [String, undefined]
31
+}, { 'd': '--verbose' });
32 32
 
33 33
 if (argv.help || argv.argv.remain.length === 0) {
34 34
     console.log('Usage: ' + path.relative(process.cwd(), path.join(__dirname, 'create')) + ' <path_to_new_project> <package_name> <project_name> [<template_path>] [--activity-name <activity_name>] [--link]');

+ 7
- 4
node_modules/cordova-android/bin/lib/create.js View File

@@ -141,9 +141,9 @@ function writeProjectProperties (projectPath, target_api) {
141 141
 }
142 142
 
143 143
 // This makes no sense, what if you're building with a different build system?
144
-function prepBuildFiles (projectPath, builder) {
144
+function prepBuildFiles (projectPath) {
145 145
     var buildModule = require(path.resolve(projectPath, 'cordova/lib/builders/builders'));
146
-    buildModule.getBuilder(builder).prepBuildFiles();
146
+    buildModule.getBuilder().prepBuildFiles();
147 147
 }
148 148
 
149 149
 function copyBuildRules (projectPath, isLegacy) {
@@ -168,7 +168,10 @@ function copyScripts (projectPath) {
168 168
     shell.rm('-rf', destScriptsDir);
169 169
     // Copy in the new ones.
170 170
     shell.cp('-r', srcScriptsDir, projectPath);
171
-    shell.cp('-r', path.join(ROOT, 'node_modules'), destScriptsDir);
171
+
172
+    let nodeModulesDir = path.join(ROOT, 'node_modules');
173
+    if (fs.existsSync(nodeModulesDir)) shell.cp('-r', nodeModulesDir, destScriptsDir);
174
+
172 175
     shell.cp(path.join(bin, 'check_reqs*'), destScriptsDir);
173 176
     shell.cp(path.join(bin, 'android_sdk_version*'), destScriptsDir);
174 177
     var check_reqs = path.join(destScriptsDir, 'check_reqs');
@@ -329,7 +332,7 @@ exports.create = function (project_path, config, options, events) {
329 332
             });
330 333
             // Link it to local android install.
331 334
             exports.writeProjectProperties(project_path, target_api);
332
-            exports.prepBuildFiles(project_path, 'studio');
335
+            exports.prepBuildFiles(project_path);
333 336
             events.emit('log', generateDoneMessage('create', options.link));
334 337
         }).thenResolve(project_path);
335 338
 };

+ 19
- 60
node_modules/cordova-android/bin/templates/cordova/Api.js View File

@@ -21,7 +21,6 @@ var path = require('path');
21 21
 var Q = require('q');
22 22
 
23 23
 var AndroidProject = require('./lib/AndroidProject');
24
-var AndroidStudio = require('./lib/AndroidStudio');
25 24
 var PluginManager = require('cordova-common').PluginManager;
26 25
 
27 26
 var CordovaLogger = require('cordova-common').CordovaLogger;
@@ -56,41 +55,27 @@ function setupEvents (externalEventEmitter) {
56 55
 function Api (platform, platformRootDir, events) {
57 56
     this.platform = PLATFORM;
58 57
     this.root = path.resolve(__dirname, '..');
59
-    this.builder = 'gradle';
60 58
 
61 59
     setupEvents(events);
62 60
 
63
-    var self = this;
61
+    const appMain = path.join(this.root, 'app', 'src', 'main');
62
+    const appRes = path.join(appMain, 'res');
64 63
 
65 64
     this.locations = {
66
-        root: self.root,
67
-        www: path.join(self.root, 'assets/www'),
68
-        res: path.join(self.root, 'res'),
69
-        platformWww: path.join(self.root, 'platform_www'),
70
-        configXml: path.join(self.root, 'res/xml/config.xml'),
71
-        defaultConfigXml: path.join(self.root, 'cordova/defaults.xml'),
72
-        strings: path.join(self.root, 'res/values/strings.xml'),
73
-        manifest: path.join(self.root, 'AndroidManifest.xml'),
74
-        build: path.join(self.root, 'build'),
75
-        javaSrc: path.join(self.root, 'src'),
65
+        root: this.root,
66
+        www: path.join(appMain, 'assets', 'www'),
67
+        res: appRes,
68
+        platformWww: path.join(this.root, 'platform_www'),
69
+        configXml: path.join(appRes, 'xml', 'config.xml'),
70
+        defaultConfigXml: path.join(this.root, 'cordova', 'defaults.xml'),
71
+        strings: path.join(appRes, 'values', 'strings.xml'),
72
+        manifest: path.join(appMain, 'AndroidManifest.xml'),
73
+        build: path.join(this.root, 'build'),
74
+        javaSrc: path.join(appMain, 'java'),
76 75
         // NOTE: Due to platformApi spec we need to return relative paths here
77 76
         cordovaJs: 'bin/templates/project/assets/www/cordova.js',
78 77
         cordovaJsSrc: 'cordova-js-src'
79 78
     };
80
-
81
-    // XXX Override some locations for Android Studio projects
82
-    if (AndroidStudio.isAndroidStudioProject(self.root) === true) {
83
-        selfEvents.emit('log', 'Android Studio project detected');
84
-        this.builder = 'studio';
85
-        this.android_studio = true;
86
-        this.locations.configXml = path.join(self.root, 'app/src/main/res/xml/config.xml');
87
-        this.locations.strings = path.join(self.root, 'app/src/main/res/values/strings.xml');
88
-        this.locations.manifest = path.join(self.root, 'app/src/main/AndroidManifest.xml');
89
-        // We could have Java Source, we could have other languages
90
-        this.locations.javaSrc = path.join(self.root, 'app/src/main/java/');
91
-        this.locations.www = path.join(self.root, 'app/src/main/assets/www');
92
-        this.locations.res = path.join(self.root, 'app/src/main/res');
93
-    }
94 79
 }
95 80
 
96 81
 /**
@@ -223,33 +208,13 @@ Api.prototype.addPlugin = function (plugin, installOptions) {
223 208
         installOptions.variables.PACKAGE_NAME = project.getPackageName();
224 209
     }
225 210
 
226
-    if (this.android_studio === true) {
227
-        installOptions.android_studio = true;
228
-    }
229
-
230 211
     return Q().then(function () {
231
-        // CB-11964: Do a clean when installing the plugin code to get around
232
-        // the Gradle bug introduced by the Android Gradle Plugin Version 2.2
233
-        // TODO: Delete when the next version of Android Gradle plugin comes out
234
-        // Since clean doesn't just clean the build, it also wipes out www, we need
235
-        // to pass additional options.
236
-
237
-        // Do some basic argument parsing
238
-        var opts = {};
239
-
240
-        // Skip cleaning prepared files when not invoking via cordova CLI.
241
-        opts.noPrepare = true;
242
-
243
-        if (!AndroidStudio.isAndroidStudioProject(self.root) && !project.isClean()) {
244
-            return self.clean(opts);
245
-        }
246
-    }).then(function () {
247 212
         return PluginManager.get(self.platform, self.locations, project).addPlugin(plugin, installOptions);
248 213
     }).then(function () {
249 214
         if (plugin.getFrameworks(this.platform).length === 0) return;
250 215
         selfEvents.emit('verbose', 'Updating build files since android plugin contained <framework>');
251 216
         // This should pick the correct builder, not just get gradle
252
-        require('./lib/builders/builders').getBuilder(this.builder).prepBuildFiles();
217
+        require('./lib/builders/builders').getBuilder().prepBuildFiles();
253 218
     }.bind(this))
254 219
         // CB-11022 Return truthy value to prevent running prepare after
255 220
         .thenResolve(true);
@@ -271,9 +236,8 @@ Api.prototype.addPlugin = function (plugin, installOptions) {
271 236
 Api.prototype.removePlugin = function (plugin, uninstallOptions) {
272 237
     var project = AndroidProject.getProjectFile(this.root);
273 238
 
274
-    if (uninstallOptions && uninstallOptions.usePlatformWww === true && this.android_studio === true) {
239
+    if (uninstallOptions && uninstallOptions.usePlatformWww === true) {
275 240
         uninstallOptions.usePlatformWww = false;
276
-        uninstallOptions.android_studio = true;
277 241
     }
278 242
 
279 243
     return PluginManager.get(this.platform, this.locations, project)
@@ -282,7 +246,7 @@ Api.prototype.removePlugin = function (plugin, uninstallOptions) {
282 246
             if (plugin.getFrameworks(this.platform).length === 0) return;
283 247
 
284 248
             selfEvents.emit('verbose', 'Updating build files since android plugin contained <framework>');
285
-            require('./lib/builders/builders').getBuilder(this.builder).prepBuildFiles();
249
+            require('./lib/builders/builders').getBuilder().prepBuildFiles();
286 250
         }.bind(this))
287 251
         // CB-11022 Return truthy value to prevent running prepare after
288 252
         .thenResolve(true);
@@ -335,9 +299,7 @@ Api.prototype.removePlugin = function (plugin, uninstallOptions) {
335 299
  */
336 300
 Api.prototype.build = function (buildOptions) {
337 301
     var self = this;
338
-    if (this.android_studio) {
339
-        buildOptions.studio = true;
340
-    }
302
+
341 303
     return require('./lib/check_reqs').run().then(function () {
342 304
         return require('./lib/build').run.call(self, buildOptions);
343 305
     }).then(function (buildResults) {
@@ -381,12 +343,9 @@ Api.prototype.run = function (runOptions) {
381 343
  */
382 344
 Api.prototype.clean = function (cleanOptions) {
383 345
     var self = this;
384
-    if (this.android_studio) {
385
-        // This will lint, checking for null won't
386
-        if (typeof cleanOptions === 'undefined') {
387
-            cleanOptions = {};
388
-        }
389
-        cleanOptions.studio = true;
346
+    // This will lint, checking for null won't
347
+    if (typeof cleanOptions === 'undefined') {
348
+        cleanOptions = {};
390 349
     }
391 350
 
392 351
     return require('./lib/check_reqs').run().then(function () {

+ 13
- 12
node_modules/cordova-android/bin/templates/cordova/build View File

@@ -19,24 +19,25 @@
19 19
        under the License.
20 20
 */
21 21
 
22
-var args  = process.argv;
22
+var args = process.argv;
23 23
 var Api = require('./Api');
24 24
 var nopt = require('nopt');
25 25
 var path = require('path');
26 26
 
27 27
 // Support basic help commands
28
-if(['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(process.argv[2]) >= 0)
28
+if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(args[2]) >= 0) {
29 29
     require('./lib/build').help();
30
+}
30 31
 
31 32
 // Do some basic argument parsing
32 33
 var buildOpts = nopt({
33
-    'verbose' : Boolean,
34
-    'silent' : Boolean,
35
-    'debug' : Boolean,
36
-    'release' : Boolean,
34
+    'verbose': Boolean,
35
+    'silent': Boolean,
36
+    'debug': Boolean,
37
+    'release': Boolean,
37 38
     'nobuild': Boolean,
38
-    'buildConfig' : path
39
-}, { 'd' : '--verbose' });
39
+    'buildConfig': path
40
+}, { 'd': '--verbose' });
40 41
 
41 42
 // Make buildOptions compatible with PlatformApi build method spec
42 43
 buildOpts.argv = buildOpts.argv.original;
@@ -44,7 +45,7 @@ buildOpts.argv = buildOpts.argv.original;
44 45
 require('./loggingHelper').adjustLoggerLevel(buildOpts);
45 46
 
46 47
 new Api().build(buildOpts)
47
-.catch(function(err) {
48
-    console.error(err.stack);
49
-    process.exit(2);
50
-});
48
+    .catch(function (err) {
49
+        console.error(err.stack);
50
+        process.exit(2);
51
+    });

+ 9
- 9
node_modules/cordova-android/bin/templates/cordova/clean View File

@@ -20,11 +20,11 @@
20 20
 */
21 21
 
22 22
 var Api = require('./Api');
23
-var path  = require('path');
23
+var path = require('path');
24 24
 var nopt = require('nopt');
25 25
 
26 26
 // Support basic help commands
27
-if(['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(process.argv[2]) >= 0) {
27
+if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(process.argv[2]) >= 0) {
28 28
     console.log('Usage: ' + path.relative(process.cwd(), process.argv[1]));
29 29
     console.log('Cleans the project directory.');
30 30
     process.exit(0);
@@ -32,9 +32,9 @@ if(['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(process.argv[2]) >=
32 32
 
33 33
 // Do some basic argument parsing
34 34
 var opts = nopt({
35
-    'verbose' : Boolean,
36
-    'silent' : Boolean
37
-}, { 'd' : '--verbose' });
35
+    'verbose': Boolean,
36
+    'silent': Boolean
37
+}, { 'd': '--verbose' });
38 38
 
39 39
 // Make buildOptions compatible with PlatformApi clean method spec
40 40
 opts.argv = opts.argv.original;
@@ -45,7 +45,7 @@ opts.noPrepare = true;
45 45
 require('./loggingHelper').adjustLoggerLevel(opts);
46 46
 
47 47
 new Api().clean(opts)
48
-.catch(function(err) {
49
-    console.error(err.stack);
50
-    process.exit(2);
51
-});
48
+    .catch(function (err) {
49
+        console.error(err.stack);
50
+        process.exit(2);
51
+    });

+ 4
- 4
node_modules/cordova-android/bin/templates/cordova/lib/Adb.js View File

@@ -44,7 +44,7 @@ function isEmulator (line) {
44 44
  *   devices/emulators
45 45
  */
46 46
 Adb.devices = function (opts) {
47
-    return spawn('adb', ['devices'], {cwd: os.tmpdir()}).then(function (output) {
47
+    return spawn('adb', ['devices'], { cwd: os.tmpdir() }).then(function (output) {
48 48
         return output.split('\n').filter(function (line) {
49 49
             // Filter out either real devices or emulators, depending on options
50 50
             return (line && opts && opts.emulators) ? isEmulator(line) : isDevice(line);
@@ -58,7 +58,7 @@ Adb.install = function (target, packagePath, opts) {
58 58
     events.emit('verbose', 'Installing apk ' + packagePath + ' on target ' + target + '...');
59 59
     var args = ['-s', target, 'install'];
60 60
     if (opts && opts.replace) args.push('-r');
61
-    return spawn('adb', args.concat(packagePath), {cwd: os.tmpdir()}).then(function (output) {
61
+    return spawn('adb', args.concat(packagePath), { cwd: os.tmpdir() }).then(function (output) {
62 62
         // 'adb install' seems to always returns no error, even if installation fails
63 63
         // so we catching output to detect installation failure
64 64
         if (output.match(/Failure/)) {
@@ -77,14 +77,14 @@ Adb.install = function (target, packagePath, opts) {
77 77
 
78 78
 Adb.uninstall = function (target, packageId) {
79 79
     events.emit('verbose', 'Uninstalling package ' + packageId + ' from target ' + target + '...');
80
-    return spawn('adb', ['-s', target, 'uninstall', packageId], {cwd: os.tmpdir()});
80
+    return spawn('adb', ['-s', target, 'uninstall', packageId], { cwd: os.tmpdir() });
81 81
 };
82 82
 
83 83
 Adb.shell = function (target, shellCommand) {
84 84
     events.emit('verbose', 'Running adb shell command "' + shellCommand + '" on target ' + target + '...');
85 85
     var args = ['-s', target, 'shell'];
86 86
     shellCommand = shellCommand.split(/\s+/);
87
-    return spawn('adb', args.concat(shellCommand), {cwd: os.tmpdir()}).catch(function (output) {
87
+    return spawn('adb', args.concat(shellCommand), { cwd: os.tmpdir() }).catch(function (output) {
88 88
         return Q.reject(new CordovaError('Failed to execute shell command "' +
89 89
             shellCommand + '"" on device: ' + output));
90 90
     });

+ 1
- 5
node_modules/cordova-android/bin/templates/cordova/lib/AndroidManifest.js View File

@@ -51,15 +51,11 @@ AndroidManifest.prototype.setVersionCode = function (versionCode) {
51 51
 };
52 52
 
53 53
 AndroidManifest.prototype.getPackageId = function () {
54
-    /* jshint -W069 */
55 54
     return this.doc.getroot().attrib['package'];
56
-    /* jshint +W069 */
57 55
 };
58 56
 
59 57
 AndroidManifest.prototype.setPackageId = function (pkgId) {
60
-    /* jshint -W069 */
61 58
     this.doc.getroot().attrib['package'] = pkgId;
62
-    /* jshint +W069 */
63 59
     return this;
64 60
 };
65 61
 
@@ -150,7 +146,7 @@ AndroidManifest.prototype.setDebuggable = function (value) {
150 146
  *   manifest will be written to file it has been read from.
151 147
  */
152 148
 AndroidManifest.prototype.write = function (destPath) {
153
-    fs.writeFileSync(destPath || this.path, this.doc.write({indent: 4}), 'utf-8');
149
+    fs.writeFileSync(destPath || this.path, this.doc.write({ indent: 4 }), 'utf-8');
154 150
 };
155 151
 
156 152
 module.exports = AndroidManifest;

+ 2
- 9
node_modules/cordova-android/bin/templates/cordova/lib/AndroidProject.js View File

@@ -21,7 +21,6 @@ var fs = require('fs');
21 21
 var path = require('path');
22 22
 var properties_parser = require('properties-parser');
23 23
 var AndroidManifest = require('./AndroidManifest');
24
-var AndroidStudio = require('./AndroidStudio');
25 24
 var pluginHandlers = require('./pluginHandlers');
26 25
 
27 26
 var projectFileCache = {};
@@ -62,10 +61,7 @@ function AndroidProject (projectDir) {
62 61
     this._dirty = false;
63 62
     this.projectDir = projectDir;
64 63
     this.platformWww = path.join(this.projectDir, 'platform_www');
65
-    this.www = path.join(this.projectDir, 'assets/www');
66
-    if (AndroidStudio.isAndroidStudioProject(projectDir) === true) {
67
-        this.www = path.join(this.projectDir, 'app/src/main/assets/www');
68
-    }
64
+    this.www = path.join(this.projectDir, 'app/src/main/assets/www');
69 65
 }
70 66
 
71 67
 AndroidProject.getProjectFile = function (projectDir) {
@@ -92,10 +88,7 @@ AndroidProject.purgeCache = function (projectDir) {
92 88
  * @return  {String}              The name of the package
93 89
  */
94 90
 AndroidProject.prototype.getPackageName = function () {
95
-    var manifestPath = path.join(this.projectDir, 'AndroidManifest.xml');
96
-    if (AndroidStudio.isAndroidStudioProject(this.projectDir) === true) {
97
-        manifestPath = path.join(this.projectDir, 'app/src/main/AndroidManifest.xml');
98
-    }
91
+    var manifestPath = path.join(this.projectDir, 'app/src/main/AndroidManifest.xml');
99 92
     return new AndroidManifest(manifestPath).getPackageId();
100 93
 };
101 94
 

+ 0
- 11
node_modules/cordova-android/bin/templates/cordova/lib/AndroidStudio.js View File

@@ -1,11 +0,0 @@
1
-/*
2
- *  This is a simple routine that checks if project is an Android Studio Project
3
- *
4
- *  @param {String} root Root folder of the project
5
- */
6
-
7
-/* jshint esnext: false */
8
-
9
-module.exports.isAndroidStudioProject = function isAndroidStudioProject (root) {
10
-    return true;
11
-};

+ 1
- 2
node_modules/cordova-android/bin/templates/cordova/lib/android_sdk.js View File

@@ -17,7 +17,6 @@
17 17
        under the License.
18 18
 */
19 19
 
20
-var Q = require('q');
21 20
 var superspawn = require('cordova-common').superspawn;
22 21
 
23 22
 var suffix_number_regex = /(\d+)$/;
@@ -95,7 +94,7 @@ module.exports.list_targets = function () {
95 94
         } else throw err;
96 95
     }).then(function (targets) {
97 96
         if (targets.length === 0) {
98
-            return Q.reject(new Error('No android targets (SDKs) installed!'));
97
+            return Promise.reject(new Error('No android targets (SDKs) installed!'));
99 98
         }
100 99
         return targets;
101 100
     });

+ 8
- 24
node_modules/cordova-android/bin/templates/cordova/lib/build.js View File

@@ -31,11 +31,10 @@ var events = require('cordova-common').events;
31 31
 var spawn = require('cordova-common').superspawn.spawn;
32 32
 var CordovaError = require('cordova-common').CordovaError;
33 33
 
34
+module.exports.parseBuildOptions = parseOpts;
34 35
 function parseOpts (options, resolvedTarget, projectRoot) {
35 36
     options = options || {};
36 37
     options.argv = nopt({
37
-        gradle: Boolean,
38
-        studio: Boolean,
39 38
         prepenv: Boolean,
40 39
         versionCode: String,
41 40
         minSdkVersion: String,
@@ -50,26 +49,13 @@ function parseOpts (options, resolvedTarget, projectRoot) {
50 49
     // Android Studio Build method is the default
51 50
     var ret = {
52 51
         buildType: options.release ? 'release' : 'debug',
53
-        buildMethod: process.env.ANDROID_BUILD || 'studio',
54 52
         prepEnv: options.argv.prepenv,
55 53
         arch: resolvedTarget && resolvedTarget.arch,
56 54
         extraArgs: []
57 55
     };
58 56
 
59
-    if (options.argv.gradle || options.argv.studio) {
60
-        ret.buildMethod = options.argv.studio ? 'studio' : 'gradle';
61
-    }
62
-
63
-    // This comes from cordova/run
64
-    if (options.studio) ret.buildMethod = 'studio';
65
-    if (options.gradle) ret.buildMethod = 'gradle';
66
-
67
-    if (options.nobuild) ret.buildMethod = 'none';
68
-
69 57
     if (options.argv.versionCode) { ret.extraArgs.push('-PcdvVersionCode=' + options.argv.versionCode); }
70
-
71 58
     if (options.argv.minSdkVersion) { ret.extraArgs.push('-PcdvMinSdkVersion=' + options.argv.minSdkVersion); }
72
-
73 59
     if (options.argv.gradleArg) {
74 60
         ret.extraArgs = ret.extraArgs.concat(options.argv.gradleArg);
75 61
     }
@@ -129,7 +115,8 @@ function parseOpts (options, resolvedTarget, projectRoot) {
129 115
  */
130 116
 module.exports.runClean = function (options) {
131 117
     var opts = parseOpts(options, null, this.root);
132
-    var builder = builders.getBuilder(opts.buildMethod);
118
+    var builder = builders.getBuilder();
119
+
133 120
     return builder.prepEnv(opts).then(function () {
134 121
         return builder.clean(opts);
135 122
     });
@@ -149,8 +136,8 @@ module.exports.runClean = function (options) {
149 136
  */
150 137
 module.exports.run = function (options, optResolvedTarget) {
151 138
     var opts = parseOpts(options, optResolvedTarget, this.root);
152
-    console.log(opts.buildMethod);
153
-    var builder = builders.getBuilder(opts.buildMethod);
139
+    var builder = builders.getBuilder();
140
+
154 141
     return builder.prepEnv(opts).then(function () {
155 142
         if (opts.prepEnv) {
156 143
             events.emit('verbose', 'Build file successfully prepared.');
@@ -161,8 +148,7 @@ module.exports.run = function (options, optResolvedTarget) {
161 148
             events.emit('log', 'Built the following apk(s): \n\t' + apkPaths.join('\n\t'));
162 149
             return {
163 150
                 apkPaths: apkPaths,
164
-                buildType: opts.buildType,
165
-                buildMethod: opts.buildMethod
151
+                buildType: opts.buildType
166 152
             };
167 153
         });
168 154
     });
@@ -276,12 +262,10 @@ module.exports.help = function () {
276 262
     console.log('Flags:');
277 263
     console.log('    \'--debug\': will build project in debug mode (default)');
278 264
     console.log('    \'--release\': will build project for release');
279
-    console.log('    \'--ant\': will build project with ant');
280
-    console.log('    \'--gradle\': will build project with gradle (default)');
281 265
     console.log('    \'--nobuild\': will skip build process (useful when using run command)');
282 266
     console.log('    \'--prepenv\': don\'t build, but copy in build scripts where necessary');
283
-    console.log('    \'--versionCode=#\': Override versionCode for this build. Useful for uploading multiple APKs. Requires --gradle.');
284
-    console.log('    \'--minSdkVersion=#\': Override minSdkVersion for this build. Useful for uploading multiple APKs. Requires --gradle.');
267
+    console.log('    \'--versionCode=#\': Override versionCode for this build. Useful for uploading multiple APKs.');
268
+    console.log('    \'--minSdkVersion=#\': Override minSdkVersion for this build. Useful for uploading multiple APKs.');
285 269
     console.log('    \'--gradleArg=<gradle command line arg>\': Extra args to pass to the gradle command. Use one flag per arg. Ex. --gradleArg=-PcdvBuildMultipleApks=true');
286 270
     console.log('');
287 271
     console.log('Signed APK flags (overwrites debug/release-signing.proprties) :');

+ 0
- 124
node_modules/cordova-android/bin/templates/cordova/lib/builders/GenericBuilder.js View File

@@ -1,124 +0,0 @@
1
-/*
2
-       Licensed to the Apache Software Foundation (ASF) under one
3
-       or more contributor license agreements.  See the NOTICE file
4
-       distributed with this work for additional information
5
-       regarding copyright ownership.  The ASF licenses this file
6
-       to you under the Apache License, Version 2.0 (the
7
-       "License"); you may not use this file except in compliance
8
-       with the License.  You may obtain a copy of the License at
9
-
10
-         http://www.apache.org/licenses/LICENSE-2.0
11
-
12
-       Unless required by applicable law or agreed to in writing,
13
-       software distributed under the License is distributed on an
14
-       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
-       KIND, either express or implied.  See the License for the
16
-       specific language governing permissions and limitations
17
-       under the License.
18
-*/
19
-/* eslint no-self-assign: 0 */
20
-/* eslint no-unused-vars: 0 */
21
-
22
-var Q = require('q');
23
-var fs = require('fs');
24
-var path = require('path');
25
-var shell = require('shelljs');
26
-var events = require('cordova-common').events;
27
-
28
-function GenericBuilder (projectDir) {
29
-    this.root = projectDir || path.resolve(__dirname, '../../..');
30
-    this.binDirs = {
31
-        studio: path.join(this.root, 'app', 'build', 'outputs', 'apk'),
32
-        gradle: path.join(this.root, 'build', 'outputs', 'apk')
33
-    };
34
-}
35
-
36
-GenericBuilder.prototype.prepEnv = function () {
37
-    return Q();
38
-};
39
-
40
-GenericBuilder.prototype.build = function () {
41
-    events.emit('log', 'Skipping build...');
42
-    return Q(null);
43
-};
44
-
45
-GenericBuilder.prototype.clean = function () {
46
-    return Q();
47
-};
48
-
49
-GenericBuilder.prototype.findOutputApks = function (build_type, arch) {
50
-    var self = this;
51
-    return Object.keys(this.binDirs).reduce(function (result, builderName) {
52
-        var binDir = self.binDirs[builderName];
53
-        return result.concat(findOutputApksHelper(binDir, build_type, builderName === 'ant' ? null : arch));
54
-    }, []).sort(apkSorter);
55
-};
56
-
57
-module.exports = GenericBuilder;
58
-
59
-function apkSorter (fileA, fileB) {
60
-    // De-prioritize arch specific builds
61
-    var archSpecificRE = /-x86|-arm/;
62
-    if (archSpecificRE.exec(fileA)) {
63
-        return 1;
64
-    } else if (archSpecificRE.exec(fileB)) {
65
-        return -1;
66
-    }
67
-
68
-    // De-prioritize unsigned builds
69
-    var unsignedRE = /-unsigned/;
70
-    if (unsignedRE.exec(fileA)) {
71
-        return 1;
72
-    } else if (unsignedRE.exec(fileB)) {
73
-        return -1;
74
-    }
75
-
76
-    var timeDiff = fs.statSync(fileB).mtime - fs.statSync(fileA).mtime;
77
-    return timeDiff === 0 ? fileA.length - fileB.length : timeDiff;
78
-}
79
-
80
-function findOutputApksHelper (dir, build_type, arch) {
81
-    var shellSilent = shell.config.silent;
82
-    shell.config.silent = true;
83
-
84
-    // list directory recursively
85
-    var ret = shell.ls('-R', dir).map(function (file) {
86
-        // ls does not include base directory
87
-        return path.join(dir, file);
88
-    }).filter(function (file) {
89
-        // find all APKs
90
-        return file.match(/\.apk?$/i);
91
-    }).filter(function (candidate) {
92
-        var apkName = path.basename(candidate);
93
-        // Need to choose between release and debug .apk.
94
-        if (build_type === 'debug') {
95
-            return /-debug/.exec(apkName) && !/-unaligned|-unsigned/.exec(apkName);
96
-        }
97
-        if (build_type === 'release') {
98
-            return /-release/.exec(apkName) && !/-unaligned/.exec(apkName);
99
-        }
100
-        return true;
101
-    }).sort(apkSorter);
102
-
103
-    shellSilent = shellSilent;
104
-
105
-    if (ret.length === 0) {
106
-        return ret;
107
-    }
108
-    // Assume arch-specific build if newest apk has -x86 or -arm.
109
-    var archSpecific = !!/-x86|-arm/.exec(path.basename(ret[0]));
110
-    // And show only arch-specific ones (or non-arch-specific)
111
-    ret = ret.filter(function (p) {
112
-        /* jshint -W018 */
113
-        return !!/-x86|-arm/.exec(path.basename(p)) === archSpecific;
114
-        /* jshint +W018 */
115
-    });
116
-
117
-    if (archSpecific && ret.length > 1 && arch) {
118
-        ret = ret.filter(function (p) {
119
-            return path.basename(p).indexOf('-' + arch) !== -1;
120
-        });
121
-    }
122
-
123
-    return ret;
124
-}

+ 0
- 331
node_modules/cordova-android/bin/templates/cordova/lib/builders/GradleBuilder.js View File

@@ -1,331 +0,0 @@
1
-/*
2
-       Licensed to the Apache Software Foundation (ASF) under one
3
-       or more contributor license agreements.  See the NOTICE file
4
-       distributed with this work for additional information
5
-       regarding copyright ownership.  The ASF licenses this file
6
-       to you under the Apache License, Version 2.0 (the
7
-       "License"); you may not use this file except in compliance
8
-       with the License.  You may obtain a copy of the License at
9
-
10
-         http://www.apache.org/licenses/LICENSE-2.0
11
-
12
-       Unless required by applicable law or agreed to in writing,
13
-       software distributed under the License is distributed on an
14
-       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
-       KIND, either express or implied.  See the License for the
16
-       specific language governing permissions and limitations
17
-       under the License.
18
-*/
19
-
20
-var Q = require('q');
21
-var fs = require('fs');
22
-var util = require('util');
23
-var path = require('path');
24
-var shell = require('shelljs');
25
-var superspawn = require('cordova-common').superspawn;
26
-var CordovaError = require('cordova-common').CordovaError;
27
-var events = require('cordova-common').events;
28
-var check_reqs = require('../check_reqs');
29
-
30
-var GenericBuilder = require('./GenericBuilder');
31
-
32
-var MARKER = 'YOUR CHANGES WILL BE ERASED!';
33
-var SIGNING_PROPERTIES = '-signing.properties';
34
-var TEMPLATE =
35
-    '# This file is automatically generated.\n' +
36
-    '# Do not modify this file -- ' + MARKER + '\n';
37
-
38
-function GradleBuilder (projectRoot) {
39
-    GenericBuilder.call(this, projectRoot);
40
-
41
-    this.binDirs = { gradle: this.binDirs.gradle };
42
-}
43
-
44
-util.inherits(GradleBuilder, GenericBuilder);
45
-
46
-GradleBuilder.prototype.getArgs = function (cmd, opts) {
47
-    if (cmd === 'release') {
48
-        cmd = 'cdvBuildRelease';
49
-    } else if (cmd === 'debug') {
50
-        cmd = 'cdvBuildDebug';
51
-    }
52
-    var args = [cmd, '-b', path.join(this.root, 'build.gradle')];
53
-    if (opts.arch) {
54
-        args.push('-PcdvBuildArch=' + opts.arch);
55
-    }
56
-
57
-    // 10 seconds -> 6 seconds
58
-    args.push('-Dorg.gradle.daemon=true');
59
-    // to allow dex in process
60
-    args.push('-Dorg.gradle.jvmargs=-Xmx2048m');
61
-    // allow NDK to be used - required by Gradle 1.5 plugin
62
-    args.push('-Pandroid.useDeprecatedNdk=true');
63
-    args.push.apply(args, opts.extraArgs);
64
-    // Shaves another 100ms, but produces a "try at own risk" warning. Not worth it (yet):
65
-    // args.push('-Dorg.gradle.parallel=true');
66
-    return args;
67
-};
68
-
69
-/*
70
- * This returns a promise
71
- */
72
-
73
-GradleBuilder.prototype.runGradleWrapper = function (gradle_cmd, gradle_file) {
74
-    var gradlePath = path.join(this.root, 'gradlew');
75
-    gradle_file = path.join(this.root, (gradle_file || 'wrapper.gradle'));
76
-    if (fs.existsSync(gradlePath)) {
77
-        // Literally do nothing, for some reason this works, while !fs.existsSync didn't on Windows
78
-    } else {
79
-        return superspawn.spawn(gradle_cmd, ['-p', this.root, 'wrapper', '-b', gradle_file], { stdio: 'pipe' })
80
-            .progress(function (stdio) {
81
-                suppressJavaOptionsInfo(stdio);
82
-            });
83
-    }
84
-};
85
-
86
-/*
87
- * We need to kill this in a fire.
88
- */
89
-
90
-GradleBuilder.prototype.readProjectProperties = function () {
91
-    function findAllUniq (data, r) {
92
-        var s = {};
93
-        var m;
94
-        while ((m = r.exec(data))) {
95
-            s[m[1]] = 1;
96
-        }
97
-        return Object.keys(s);
98
-    }
99
-
100
-    var data = fs.readFileSync(path.join(this.root, 'project.properties'), 'utf8');
101
-    return {
102
-        libs: findAllUniq(data, /^\s*android\.library\.reference\.\d+=(.*)(?:\s|$)/mg),
103
-        gradleIncludes: findAllUniq(data, /^\s*cordova\.gradle\.include\.\d+=(.*)(?:\s|$)/mg),
104
-        systemLibs: findAllUniq(data, /^\s*cordova\.system\.library\.\d+=(.*)(?:\s|$)/mg)
105
-    };
106
-};
107
-
108
-GradleBuilder.prototype.extractRealProjectNameFromManifest = function () {
109
-    var manifestPath = path.join(this.root, 'AndroidManifest.xml');
110
-    var manifestData = fs.readFileSync(manifestPath, 'utf8');
111
-    var m = /<manifest[\s\S]*?package\s*=\s*"(.*?)"/i.exec(manifestData);
112
-    if (!m) {
113
-        throw new CordovaError('Could not find package name in ' + manifestPath);
114
-    }
115
-
116
-    var packageName = m[1];
117
-    var lastDotIndex = packageName.lastIndexOf('.');
118
-    return packageName.substring(lastDotIndex + 1);
119
-};
120
-
121
-// Makes the project buildable, minus the gradle wrapper.
122
-GradleBuilder.prototype.prepBuildFiles = function () {
123
-    // Update the version of build.gradle in each dependent library.
124
-    var pluginBuildGradle = path.join(this.root, 'cordova', 'lib', 'plugin-build.gradle');
125
-    var propertiesObj = this.readProjectProperties();
126
-    var subProjects = propertiesObj.libs;
127
-
128
-    // Check and copy the gradle file into the subproject.
129
-    // Called by the loop below this function def.
130
-    var checkAndCopy = function (subProject, root) {
131
-        var subProjectGradle = path.join(root, subProject, 'build.gradle');
132
-        // This is the future-proof way of checking if a file exists
133
-        // This must be synchronous to satisfy a Travis test
134
-        try {
135
-            fs.accessSync(subProjectGradle, fs.F_OK);
136
-        } catch (e) {
137
-            shell.cp('-f', pluginBuildGradle, subProjectGradle);
138
-        }
139
-    };
140
-
141
-    // Some dependencies on Android don't use gradle, or don't have default
142
-    // gradle files.  This copies a dummy gradle file into them
143
-    for (var i = 0; i < subProjects.length; ++i) {
144
-        if (subProjects[i] !== 'CordovaLib' && subProjects[i] !== 'app') {
145
-            checkAndCopy(subProjects[i], this.root);
146
-        }
147
-    }
148
-
149
-    var name = this.extractRealProjectNameFromManifest();
150
-    // Remove the proj.id/name- prefix from projects: https://issues.apache.org/jira/browse/CB-9149
151
-    var settingsGradlePaths = subProjects.map(function (p) {
152
-        var realDir = p.replace(/[/\\]/g, ':');
153
-        var libName = realDir.replace(name + '-', '');
154
-        var str = 'include ":' + libName + '"\n';
155
-        if (realDir.indexOf(name + '-') !== -1) { str += 'project(":' + libName + '").projectDir = new File("' + p + '")\n'; }
156
-        return str;
157
-    });
158
-
159
-    // Write the settings.gradle file.
160
-    fs.writeFileSync(path.join(this.root, 'settings.gradle'),
161
-        '// GENERATED FILE - DO NOT EDIT\n' +
162
-        'include ":"\n' + settingsGradlePaths.join(''));
163
-    // Update dependencies within build.gradle.
164
-    var buildGradle = fs.readFileSync(path.join(this.root, 'build.gradle'), 'utf8');
165
-    var depsList = '';
166
-    var root = this.root;
167
-
168
-    // Cordova Plugins can be written as library modules that would use Cordova as a
169
-    // dependency.  Because we need to make sure that Cordova is compiled only once for
170
-    // dexing, we make sure to exclude CordovaLib from these modules
171
-    var insertExclude = function (p) {
172
-        var gradlePath = path.join(root, p, 'build.gradle');
173
-        var projectGradleFile = fs.readFileSync(gradlePath, 'utf-8');
174
-        if (projectGradleFile.indexOf('CordovaLib') !== -1) {
175
-            depsList += '{\n        exclude module:("CordovaLib")\n    }\n';
176
-        } else {
177
-            depsList += '\n';
178
-        }
179
-    };
180
-
181
-    subProjects.forEach(function (p) {
182
-        events.emit('log', 'Subproject Path: ' + p);
183
-        var libName = p.replace(/[/\\]/g, ':').replace(name + '-', '');
184
-        depsList += '    implementation(project(path: "' + libName + '"))';
185
-        insertExclude(p);
186
-    });
187
-
188
-    // For why we do this mapping: https://issues.apache.org/jira/browse/CB-8390
189
-    var SYSTEM_LIBRARY_MAPPINGS = [
190
-        [/^\/?extras\/android\/support\/(.*)$/, 'com.android.support:support-$1:+'],
191
-        [/^\/?google\/google_play_services\/libproject\/google-play-services_lib\/?$/, 'com.google.android.gms:play-services:+']
192
-    ];
193
-    propertiesObj.systemLibs.forEach(function (p) {
194
-        var mavenRef;
195
-        // It's already in gradle form if it has two ':'s
196
-        if (/:.*:/.exec(p)) {
197
-            mavenRef = p;
198
-        } else {
199
-            for (var i = 0; i < SYSTEM_LIBRARY_MAPPINGS.length; ++i) {
200
-                var pair = SYSTEM_LIBRARY_MAPPINGS[i];
201
-                if (pair[0].exec(p)) {
202
-                    mavenRef = p.replace(pair[0], pair[1]);
203
-                    break;
204
-                }
205
-            }
206
-            if (!mavenRef) {
207
-                throw new CordovaError('Unsupported system library (does not work with gradle): ' + p);
208
-            }
209
-        }
210
-        depsList += '    compile "' + mavenRef + '"\n';
211
-    });
212
-
213
-    // This code is dangerous and actually writes gradle declarations directly into the build.gradle
214
-    // Try not to mess with this if possible
215
-    buildGradle = buildGradle.replace(/(SUB-PROJECT DEPENDENCIES START)[\s\S]*(\/\/ SUB-PROJECT DEPENDENCIES END)/, '$1\n' + depsList + '    $2');
216
-    var includeList = '';
217
-    propertiesObj.gradleIncludes.forEach(function (includePath) {
218
-        includeList += 'apply from: "' + includePath + '"\n';
219
-    });
220
-    buildGradle = buildGradle.replace(/(PLUGIN GRADLE EXTENSIONS START)[\s\S]*(\/\/ PLUGIN GRADLE EXTENSIONS END)/, '$1\n' + includeList + '$2');
221
-    fs.writeFileSync(path.join(this.root, 'build.gradle'), buildGradle);
222
-};
223
-
224
-GradleBuilder.prototype.prepEnv = function (opts) {
225
-    var self = this;
226
-    return check_reqs.check_gradle().then(function (gradlePath) {
227
-        return self.runGradleWrapper(gradlePath);
228
-    }).then(function () {
229
-        return self.prepBuildFiles();
230
-    }).then(function () {
231
-        // We now copy the gradle out of the framework
232
-        // This is a dirty patch to get the build working
233
-        /*
234
-        var wrapperDir = path.join(self.root, 'CordovaLib');
235
-        if (process.platform == 'win32') {
236
-            shell.rm('-f', path.join(self.root, 'gradlew.bat'));
237
-            shell.cp(path.join(wrapperDir, 'gradlew.bat'), self.root);
238
-        } else {
239
-            shell.rm('-f', path.join(self.root, 'gradlew'));
240
-            shell.cp(path.join(wrapperDir, 'gradlew'), self.root);
241
-        }
242
-        shell.rm('-rf', path.join(self.root, 'gradle', 'wrapper'));
243
-        shell.mkdir('-p', path.join(self.root, 'gradle'));
244
-        shell.cp('-r', path.join(wrapperDir, 'gradle', 'wrapper'), path.join(self.root, 'gradle'));
245
-*/
246
-        // If the gradle distribution URL is set, make sure it points to version we want.
247
-        // If it's not set, do nothing, assuming that we're using a future version of gradle that we don't want to mess with.
248
-        // For some reason, using ^ and $ don't work.  This does the job, though.
249
-        var distributionUrlRegex = /distributionUrl.*zip/;
250
-        /* jshint -W069 */
251
-        var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'https\\://services.gradle.org/distributions/gradle-4.1-all.zip';
252
-        /* jshint +W069 */
253
-        var gradleWrapperPropertiesPath = path.join(self.root, 'gradle', 'wrapper', 'gradle-wrapper.properties');
254
-        shell.chmod('u+w', gradleWrapperPropertiesPath);
255
-        shell.sed('-i', distributionUrlRegex, 'distributionUrl=' + distributionUrl, gradleWrapperPropertiesPath);
256
-
257
-        var propertiesFile = opts.buildType + SIGNING_PROPERTIES;
258
-        var propertiesFilePath = path.join(self.root, propertiesFile);
259
-        if (opts.packageInfo) {
260
-            fs.writeFileSync(propertiesFilePath, TEMPLATE + opts.packageInfo.toProperties());
261
-        } else if (isAutoGenerated(propertiesFilePath)) {
262
-            shell.rm('-f', propertiesFilePath);
263
-        }
264
-    });
265
-};
266
-
267
-/*
268
- * Builds the project with gradle.
269
- * Returns a promise.
270
- */
271
-GradleBuilder.prototype.build = function (opts) {
272
-    var wrapper = path.join(this.root, 'gradlew');
273
-    var args = this.getArgs(opts.buildType === 'debug' ? 'debug' : 'release', opts);
274
-
275
-    return superspawn.spawn(wrapper, args, { stdio: 'pipe' })
276
-        .progress(function (stdio) {
277
-            suppressJavaOptionsInfo(stdio);
278
-        }).catch(function (error) {
279
-            if (error.toString().indexOf('failed to find target with hash string') >= 0) {
280
-                return check_reqs.check_android_target(error).then(function () {
281
-                    // If due to some odd reason - check_android_target succeeds
282
-                    // we should still fail here.
283
-                    return Q.reject(error);
284
-                });
285
-            }
286
-            return Q.reject(error);
287
-        });
288
-};
289
-
290
-GradleBuilder.prototype.clean = function (opts) {
291
-    var builder = this;
292
-    var wrapper = path.join(this.root, 'gradlew');
293
-    var args = builder.getArgs('clean', opts);
294
-    return Q().then(function () {
295
-        return superspawn.spawn(wrapper, args, { stdio: 'inherit' });
296
-    }).then(function () {
297
-        shell.rm('-rf', path.join(builder.root, 'out'));
298
-
299
-        ['debug', 'release'].forEach(function (config) {
300
-            var propertiesFilePath = path.join(builder.root, config + SIGNING_PROPERTIES);
301
-            if (isAutoGenerated(propertiesFilePath)) {
302
-                shell.rm('-f', propertiesFilePath);
303
-            }
304
-        });
305
-    });
306
-};
307
-
308
-module.exports = GradleBuilder;
309
-
310
-function suppressJavaOptionsInfo (stdio) {
311
-    if (stdio.stderr) {
312
-        /*
313
-         * Workaround for the issue with Java printing some unwanted information to
314
-         * stderr instead of stdout.
315
-         * This function suppresses 'Picked up _JAVA_OPTIONS' message from being
316
-         * printed to stderr. See https://issues.apache.org/jira/browse/CB-9971 for
317
-         * explanation.
318
-         */
319
-        var suppressThisLine = /^Picked up _JAVA_OPTIONS: /i.test(stdio.stderr.toString());
320
-        if (suppressThisLine) {
321
-            return;
322
-        }
323
-        process.stderr.write(stdio.stderr);
324
-    } else {
325
-        process.stdout.write(stdio.stdout);
326
-    }
327
-}
328
-
329
-function isAutoGenerated (file) {
330
-    return fs.existsSync(file) && fs.readFileSync(file, 'utf8').indexOf(MARKER) > 0;
331
-}

+ 0
- 303
node_modules/cordova-android/bin/templates/cordova/lib/builders/StudioBuilder.js View File

@@ -1,303 +0,0 @@
1
-/*
2
-       Licensed to the Apache Software Foundation (ASF) under one
3
-       or more contributor license agreements.  See the NOTICE file
4
-       distributed with this work for additional information
5
-       regarding copyright ownership.  The ASF licenses this file
6
-       to you under the Apache License, Version 2.0 (the
7
-       "License"); you may not use this file except in compliance
8
-       with the License.  You may obtain a copy of the License at
9
-
10
-         http://www.apache.org/licenses/LICENSE-2.0
11
-
12
-       Unless required by applicable law or agreed to in writing,
13
-       software distributed under the License is distributed on an
14
-       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
-       KIND, either express or implied.  See the License for the
16
-       specific language governing permissions and limitations
17
-       under the License.
18
-*/
19
-
20
-var Q = require('q');
21
-var fs = require('fs');
22
-var util = require('util');
23
-var path = require('path');
24
-var shell = require('shelljs');
25
-var spawn = require('cordova-common').superspawn.spawn;
26
-var events = require('cordova-common').events;
27
-var CordovaError = require('cordova-common').CordovaError;
28
-var check_reqs = require('../check_reqs');
29
-
30
-var GenericBuilder = require('./GenericBuilder');
31
-
32
-var MARKER = 'YOUR CHANGES WILL BE ERASED!';
33
-var SIGNING_PROPERTIES = '-signing.properties';
34
-var TEMPLATE =
35
-    '# This file is automatically generated.\n' +
36
-    '# Do not modify this file -- ' + MARKER + '\n';
37
-
38
-function StudioBuilder (projectRoot) {
39
-    GenericBuilder.call(this, projectRoot);
40
-
41
-    this.binDirs = {gradle: this.binDirs.studio};
42
-}
43
-
44
-util.inherits(StudioBuilder, GenericBuilder);
45
-
46
-StudioBuilder.prototype.getArgs = function (cmd, opts) {
47
-    if (cmd === 'release') {
48
-        cmd = 'cdvBuildRelease';
49
-    } else if (cmd === 'debug') {
50
-        cmd = 'cdvBuildDebug';
51
-    }
52
-    var args = [cmd, '-b', path.join(this.root, 'build.gradle')];
53
-    if (opts.arch) {
54
-        args.push('-PcdvBuildArch=' + opts.arch);
55
-    }
56
-
57
-    // 10 seconds -> 6 seconds
58
-    args.push('-Dorg.gradle.daemon=true');
59
-    // to allow dex in process
60
-    args.push('-Dorg.gradle.jvmargs=-Xmx2048m');
61
-    // allow NDK to be used - required by Gradle 1.5 plugin
62
-    // args.push('-Pandroid.useDeprecatedNdk=true');
63
-    args.push.apply(args, opts.extraArgs);
64
-    // Shaves another 100ms, but produces a "try at own risk" warning. Not worth it (yet):
65
-    // args.push('-Dorg.gradle.parallel=true');
66
-    return args;
67
-};
68
-
69
-/*
70
- * This returns a promise
71
- */
72
-
73
-StudioBuilder.prototype.runGradleWrapper = function (gradle_cmd) {
74
-    var gradlePath = path.join(this.root, 'gradlew');
75
-    var wrapperGradle = path.join(this.root, 'wrapper.gradle');
76
-    if (fs.existsSync(gradlePath)) {
77
-        // Literally do nothing, for some reason this works, while !fs.existsSync didn't on Windows
78
-    } else {
79
-        return spawn(gradle_cmd, ['-p', this.root, 'wrapper', '-b', wrapperGradle], {stdio: 'inherit'});
80
-    }
81
-};
82
-
83
-StudioBuilder.prototype.readProjectProperties = function () {
84
-
85
-    function findAllUniq (data, r) {
86
-        var s = {};
87
-        var m;
88
-        while ((m = r.exec(data))) {
89
-            s[m[1]] = 1;
90
-        }
91
-        return Object.keys(s);
92
-    }
93
-
94
-    var data = fs.readFileSync(path.join(this.root, 'project.properties'), 'utf8');
95
-    return {
96
-        libs: findAllUniq(data, /^\s*android\.library\.reference\.\d+=(.*)(?:\s|$)/mg),
97
-        gradleIncludes: findAllUniq(data, /^\s*cordova\.gradle\.include\.\d+=(.*)(?:\s|$)/mg),
98
-        systemLibs: findAllUniq(data, /^\s*cordova\.system\.library\.\d+=(.*)(?:\s|$)/mg)
99
-    };
100
-};
101
-
102
-StudioBuilder.prototype.extractRealProjectNameFromManifest = function () {
103
-    var manifestPath = path.join(this.root, 'app', 'src', 'main', 'AndroidManifest.xml');
104
-    var manifestData = fs.readFileSync(manifestPath, 'utf8');
105
-    var m = /<manifest[\s\S]*?package\s*=\s*"(.*?)"/i.exec(manifestData);
106
-    if (!m) {
107
-        throw new CordovaError('Could not find package name in ' + manifestPath);
108
-    }
109
-
110
-    var packageName = m[1];
111
-    var lastDotIndex = packageName.lastIndexOf('.');
112
-    return packageName.substring(lastDotIndex + 1);
113
-};
114
-
115
-// Makes the project buildable, minus the gradle wrapper.
116
-StudioBuilder.prototype.prepBuildFiles = function () {
117
-    // Update the version of build.gradle in each dependent library.
118
-    var pluginBuildGradle = path.join(this.root, 'cordova', 'lib', 'plugin-build.gradle');
119
-    var propertiesObj = this.readProjectProperties();
120
-    var subProjects = propertiesObj.libs;
121
-
122
-    // Check and copy the gradle file into the subproject
123
-    // Called by the loop before this function def
124
-
125
-    var checkAndCopy = function (subProject, root) {
126
-        var subProjectGradle = path.join(root, subProject, 'build.gradle');
127
-        // This is the future-proof way of checking if a file exists
128
-        // This must be synchronous to satisfy a Travis test
129
-        try {
130
-            fs.accessSync(subProjectGradle, fs.F_OK);
131
-        } catch (e) {
132
-            shell.cp('-f', pluginBuildGradle, subProjectGradle);
133
-        }
134
-    };
135
-
136
-    for (var i = 0; i < subProjects.length; ++i) {
137
-        if (subProjects[i] !== 'CordovaLib') {
138
-            checkAndCopy(subProjects[i], this.root);
139
-        }
140
-    }
141
-    var name = this.extractRealProjectNameFromManifest();
142
-    // Remove the proj.id/name- prefix from projects: https://issues.apache.org/jira/browse/CB-9149
143
-    var settingsGradlePaths = subProjects.map(function (p) {
144
-        var realDir = p.replace(/[/\\]/g, ':');
145
-        var libName = realDir.replace(name + '-', '');
146
-        var str = 'include ":' + libName + '"\n';
147
-        if (realDir.indexOf(name + '-') !== -1) {
148
-            str += 'project(":' + libName + '").projectDir = new File("' + p + '")\n';
149
-        }
150
-        return str;
151
-    });
152
-
153
-    fs.writeFileSync(path.join(this.root, 'settings.gradle'),
154
-        '// GENERATED FILE - DO NOT EDIT\n' +
155
-        'include ":"\n' + settingsGradlePaths.join(''));
156
-
157
-    // Update dependencies within build.gradle.
158
-    var buildGradle = fs.readFileSync(path.join(this.root, 'app', 'build.gradle'), 'utf8');
159
-    var depsList = '';
160
-    var root = this.root;
161
-    var insertExclude = function (p) {
162
-        var gradlePath = path.join(root, p, 'build.gradle');
163
-        var projectGradleFile = fs.readFileSync(gradlePath, 'utf-8');
164
-        if (projectGradleFile.indexOf('CordovaLib') !== -1) {
165
-            depsList += '{\n        exclude module:("CordovaLib")\n    }\n';
166
-        } else {
167
-            depsList += '\n';
168
-        }
169
-    };
170
-    subProjects.forEach(function (p) {
171
-        events.emit('log', 'Subproject Path: ' + p);
172
-        var libName = p.replace(/[/\\]/g, ':').replace(name + '-', '');
173
-        if (libName !== 'app') {
174
-            depsList += '    implementation(project(path: ":' + libName + '"))';
175
-            insertExclude(p);
176
-        }
177
-    });
178
-    // For why we do this mapping: https://issues.apache.org/jira/browse/CB-8390
179
-    var SYSTEM_LIBRARY_MAPPINGS = [
180
-        [/^\/?extras\/android\/support\/(.*)$/, 'com.android.support:support-$1:+'],
181
-        [/^\/?google\/google_play_services\/libproject\/google-play-services_lib\/?$/, 'com.google.android.gms:play-services:+']
182
-    ];
183
-
184
-    propertiesObj.systemLibs.forEach(function (p) {
185
-        var mavenRef;
186
-        // It's already in gradle form if it has two ':'s
187
-        if (/:.*:/.exec(p)) {
188
-            mavenRef = p;
189
-        } else {
190
-            for (var i = 0; i < SYSTEM_LIBRARY_MAPPINGS.length; ++i) {
191
-                var pair = SYSTEM_LIBRARY_MAPPINGS[i];
192
-                if (pair[0].exec(p)) {
193
-                    mavenRef = p.replace(pair[0], pair[1]);
194
-                    break;
195
-                }
196
-            }
197
-            if (!mavenRef) {
198
-                throw new CordovaError('Unsupported system library (does not work with gradle): ' + p);
199
-            }
200
-        }
201
-        depsList += '    compile "' + mavenRef + '"\n';
202
-    });
203
-
204
-    buildGradle = buildGradle.replace(/(SUB-PROJECT DEPENDENCIES START)[\s\S]*(\/\/ SUB-PROJECT DEPENDENCIES END)/, '$1\n' + depsList + '    $2');
205
-    var includeList = '';
206
-
207
-    propertiesObj.gradleIncludes.forEach(function (includePath) {
208
-        includeList += 'apply from: "../' + includePath + '"\n';
209
-    });
210
-    buildGradle = buildGradle.replace(/(PLUGIN GRADLE EXTENSIONS START)[\s\S]*(\/\/ PLUGIN GRADLE EXTENSIONS END)/, '$1\n' + includeList + '$2');
211
-    // This needs to be stored in the app gradle, not the root grade
212
-    fs.writeFileSync(path.join(this.root, 'app', 'build.gradle'), buildGradle);
213
-};
214
-
215
-StudioBuilder.prototype.prepEnv = function (opts) {
216
-    var self = this;
217
-    return check_reqs.check_gradle()
218
-        .then(function (gradlePath) {
219
-            return self.runGradleWrapper(gradlePath);
220
-        }).then(function () {
221
-            return self.prepBuildFiles();
222
-        }).then(function () {
223
-            // If the gradle distribution URL is set, make sure it points to version we want.
224
-            // If it's not set, do nothing, assuming that we're using a future version of gradle that we don't want to mess with.
225
-            // For some reason, using ^ and $ don't work.  This does the job, though.
226
-            var distributionUrlRegex = /distributionUrl.*zip/;
227
-            var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'https\\://services.gradle.org/distributions/gradle-4.1-all.zip';
228
-            var gradleWrapperPropertiesPath = path.join(self.root, 'gradle', 'wrapper', 'gradle-wrapper.properties');
229
-            shell.chmod('u+w', gradleWrapperPropertiesPath);
230
-            shell.sed('-i', distributionUrlRegex, 'distributionUrl=' + distributionUrl, gradleWrapperPropertiesPath);
231
-
232
-            var propertiesFile = opts.buildType + SIGNING_PROPERTIES;
233
-            var propertiesFilePath = path.join(self.root, propertiesFile);
234
-            if (opts.packageInfo) {
235
-                fs.writeFileSync(propertiesFilePath, TEMPLATE + opts.packageInfo.toProperties());
236
-            } else if (isAutoGenerated(propertiesFilePath)) {
237
-                shell.rm('-f', propertiesFilePath);
238
-            }
239
-        });
240
-};
241
-
242
-/*
243
- * Builds the project with gradle.
244
- * Returns a promise.
245
- */
246
-StudioBuilder.prototype.build = function (opts) {
247
-    var wrapper = path.join(this.root, 'gradlew');
248
-    var args = this.getArgs(opts.buildType === 'debug' ? 'debug' : 'release', opts);
249
-
250
-    return spawn(wrapper, args, {stdio: 'pipe'})
251
-        .progress(function (stdio) {
252
-            if (stdio.stderr) {
253
-                /*
254
-                 * Workaround for the issue with Java printing some unwanted information to
255
-                 * stderr instead of stdout.
256
-                 * This function suppresses 'Picked up _JAVA_OPTIONS' message from being
257
-                 * printed to stderr. See https://issues.apache.org/jira/browse/CB-9971 for
258
-                 * explanation.
259
-                 */
260
-                var suppressThisLine = /^Picked up _JAVA_OPTIONS: /i.test(stdio.stderr.toString());
261
-                if (suppressThisLine) {
262
-                    return;
263
-                }
264
-                process.stderr.write(stdio.stderr);
265
-            } else {
266
-                process.stdout.write(stdio.stdout);
267
-            }
268
-        }).catch(function (error) {
269
-            if (error.toString().indexOf('failed to find target with hash string') >= 0) {
270
-                return check_reqs.check_android_target(error).then(function () {
271
-                    // If due to some odd reason - check_android_target succeeds
272
-                    // we should still fail here.
273
-                    return Q.reject(error);
274
-                });
275
-            }
276
-            return Q.reject(error);
277
-        });
278
-};
279
-
280
-StudioBuilder.prototype.clean = function (opts) {
281
-    var builder = this;
282
-    var wrapper = path.join(this.root, 'gradlew');
283
-    var args = builder.getArgs('clean', opts);
284
-    return Q().then(function () {
285
-        return spawn(wrapper, args, {stdio: 'inherit'});
286
-    })
287
-        .then(function () {
288
-            shell.rm('-rf', path.join(builder.root, 'out'));
289
-
290
-            ['debug', 'release'].forEach(function (config) {
291
-                var propertiesFilePath = path.join(builder.root, config + SIGNING_PROPERTIES);
292
-                if (isAutoGenerated(propertiesFilePath)) {
293
-                    shell.rm('-f', propertiesFilePath);
294
-                }
295
-            });
296
-        });
297
-};
298
-
299
-module.exports = StudioBuilder;
300
-
301
-function isAutoGenerated (file) {
302
-    return fs.existsSync(file) && fs.readFileSync(file, 'utf8').indexOf(MARKER) > 0;
303
-}

+ 21
- 33
node_modules/cordova-android/bin/templates/cordova/lib/builders/builders.js View File

@@ -1,46 +1,34 @@
1 1
 /*
2
-       Licensed to the Apache Software Foundation (ASF) under one
3
-       or more contributor license agreements.  See the NOTICE file
4
-       distributed with this work for additional information
5
-       regarding copyright ownership.  The ASF licenses this file
6
-       to you under the Apache License, Version 2.0 (the
7
-       "License"); you may not use this file except in compliance
8
-       with the License.  You may obtain a copy of the License at
2
+    Licensed to the Apache Software Foundation (ASF) under one
3
+    or more contributor license agreements.  See the NOTICE file
4
+    distributed with this work for additional information
5
+    regarding copyright ownership.  The ASF licenses this file
6
+    to you under the Apache License, Version 2.0 (the
7
+    "License"); you may not use this file except in compliance
8
+    with the License.  You may obtain a copy of the License at
9 9
 
10
-         http://www.apache.org/licenses/LICENSE-2.0
10
+        http://www.apache.org/licenses/LICENSE-2.0
11 11
 
12
-       Unless required by applicable law or agreed to in writing,
13
-       software distributed under the License is distributed on an
14
-       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
-       KIND, either express or implied.  See the License for the
16
-       specific language governing permissions and limitations
17
-       under the License.
12
+    Unless required by applicable law or agreed to in writing,
13
+    software distributed under the License is distributed on an
14
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+    KIND, either express or implied.  See the License for the
16
+    specific language governing permissions and limitations
17
+    under the License.
18 18
 */
19 19
 
20
-var CordovaError = require('cordova-common').CordovaError;
21
-
22
-var knownBuilders = {
23
-    gradle: 'GradleBuilder',
24
-    studio: 'StudioBuilder',
25
-    none: 'GenericBuilder'
26
-};
20
+const CordovaError = require('cordova-common').CordovaError;
27 21
 
28 22
 /**
29
- * Helper method that instantiates and returns a builder for specified build
30
- *   type.
23
+ * Helper method that instantiates and returns a builder for specified build type.
31 24
  *
32
- * @param   {String}  builderType   Builder name to construct and return. Must
33
- *   be one of 'ant', 'gradle' or 'none'
34
- *
35
- * @return  {Builder}               A builder instance for specified build type.
25
+ * @return {Builder} A builder instance for specified build type.
36 26
  */
37
-module.exports.getBuilder = function (builderType, projectRoot) {
38
-    if (!knownBuilders[builderType]) { throw new CordovaError('Builder ' + builderType + ' is not supported.'); }
39
-
27
+module.exports.getBuilder = function () {
40 28
     try {
41
-        var Builder = require('./' + knownBuilders[builderType]);
42
-        return new Builder(projectRoot);
29
+        const Builder = require('./ProjectBuilder');
30
+        return new Builder();
43 31
     } catch (err) {
44
-        throw new CordovaError('Failed to instantiate ' + knownBuilders[builderType] + ' builder: ' + err);
32
+        throw new CordovaError('Failed to instantiate ProjectBuilder builder: ' + err);
45 33
     }
46 34
 };

+ 21
- 9
node_modules/cordova-android/bin/templates/cordova/lib/check_reqs.js View File

@@ -19,8 +19,6 @@
19 19
        under the License.
20 20
 */
21 21
 
22
-/* jshint sub:true */
23
-
24 22
 var shelljs = require('shelljs');
25 23
 var child_process = require('child_process');
26 24
 var Q = require('q');
@@ -205,10 +203,12 @@ module.exports.check_java = function () {
205 203
                 return match && match[1];
206 204
             }, () => {
207 205
                 var msg =
208
-                'Failed to run "javac -version", make sure that you have a JDK installed.\n' +
209
-                'You can get it from: http://www.oracle.com/technetwork/java/javase/downloads.\n';
206
+                'Failed to run "javac -version", make sure that you have a JDK version 8 installed.\n' +
207
+                'You can get it from the following location:\n' +
208
+                'https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html';
210 209
                 if (process.env['JAVA_HOME']) {
211
-                    msg += 'Your JAVA_HOME is invalid: ' + process.env['JAVA_HOME'] + '\n';
210
+                    msg += '\n\n';
211
+                    msg += 'Your JAVA_HOME is invalid: ' + process.env['JAVA_HOME'];
212 212
                 }
213 213
                 throw new CordovaError(msg);
214 214
             });
@@ -231,6 +231,14 @@ module.exports.check_android = function () {
231 231
         // First ensure ANDROID_HOME is set
232 232
         // If we have no hints (nothing in PATH), try a few default locations
233 233
         if (!hasAndroidHome && !androidCmdPath && !adbInPath && !avdmanagerInPath) {
234
+            if (process.env['ANDROID_SDK_ROOT']) {
235
+                // Quick fix to set ANDROID_HOME according to ANDROID_SDK_ROOT
236
+                // if ANDROID_HOME is **not** defined and
237
+                // ANDROID_SDK_ROOT **is** defined
238
+                // according to environment variables as documented in:
239
+                // https://developer.android.com/studio/command-line/variables
240
+                maybeSetAndroidHome(path.join(process.env['ANDROID_SDK_ROOT']));
241
+            }
234 242
             if (module.exports.isWindows()) {
235 243
                 // Android Studio 1.0 installer
236 244
                 maybeSetAndroidHome(path.join(process.env['LOCALAPPDATA'], 'Android', 'sdk'));
@@ -355,15 +363,19 @@ module.exports.check_android_target = function (originalError) {
355 363
 // Returns a promise.
356 364
 module.exports.run = function () {
357 365
     return Q.all([this.check_java(), this.check_android()]).then(function (values) {
358
-        console.log('ANDROID_HOME=' + process.env['ANDROID_HOME']);
359
-        console.log('JAVA_HOME=' + process.env['JAVA_HOME']);
366
+        console.log('Checking Java JDK and Android SDK versions');
367
+        console.log('ANDROID_SDK_ROOT=' + process.env['ANDROID_SDK_ROOT'] + ' (recommended setting)');
368
+        console.log('ANDROID_HOME=' + process.env['ANDROID_HOME'] + ' (DEPRECATED)');
360 369
 
361 370
         if (!String(values[0]).startsWith('1.8.')) {
362
-            throw new CordovaError('Requirements check failed for JDK 1.8');
371
+            throw new CordovaError(
372
+                'Requirements check failed for JDK 8 (\'1.8.*\')! Detected version: ' + values[0] + '\n' +
373
+                'Check your ANDROID_SDK_ROOT / JAVA_HOME / PATH environment variables.'
374
+            );
363 375
         }
364 376
 
365 377
         if (!values[1]) {
366
-            throw new CordovaError('Requirements check failed for Android SDK');
378
+            throw new CordovaError('Requirements check failed for Android SDK! Android SDK was not detected.');
367 379
         }
368 380
     });
369 381
 };

+ 5
- 6
node_modules/cordova-android/bin/templates/cordova/lib/device.js View File

@@ -19,7 +19,6 @@
19 19
        under the License.
20 20
 */
21 21
 
22
-var Q = require('q');
23 22
 var build = require('./build');
24 23
 var path = require('path');
25 24
 var Adb = require('./Adb');
@@ -53,13 +52,13 @@ module.exports.list = function (lookHarder) {
53 52
 module.exports.resolveTarget = function (target) {
54 53
     return this.list(true).then(function (device_list) {
55 54
         if (!device_list || !device_list.length) {
56
-            return Q.reject(new CordovaError('Failed to deploy to device, no devices found.'));
55
+            return Promise.reject(new CordovaError('Failed to deploy to device, no devices found.'));
57 56
         }
58 57
         // default device
59 58
         target = target || device_list[0];
60 59
 
61 60
         if (device_list.indexOf(target) < 0) {
62
-            return Q.reject('ERROR: Unable to find target \'' + target + '\'.');
61
+            return Promise.reject(new CordovaError('ERROR: Unable to find target \'' + target + '\'.'));
63 62
         }
64 63
 
65 64
         return build.detectArchitecture(target).then(function (arch) {
@@ -74,7 +73,7 @@ module.exports.resolveTarget = function (target) {
74 73
  * Returns a promise.
75 74
  */
76 75
 module.exports.install = function (target, buildResults) {
77
-    return Q().then(function () {
76
+    return Promise.resolve().then(function () {
78 77
         if (target && typeof target === 'object') {
79 78
             return target;
80 79
         }
@@ -87,7 +86,7 @@ module.exports.install = function (target, buildResults) {
87 86
         events.emit('log', 'Using apk: ' + apk_path);
88 87
         events.emit('log', 'Package name: ' + pkgName);
89 88
 
90
-        return Adb.install(resolvedTarget.target, apk_path, {replace: true}).catch(function (error) {
89
+        return Adb.install(resolvedTarget.target, apk_path, { replace: true }).catch(function (error) {
91 90
             // CB-9557 CB-10157 only uninstall and reinstall app if the one that
92 91
             // is already installed on device was signed w/different certificate
93 92
             if (!/INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES/.test(error.toString())) { throw error; }
@@ -98,7 +97,7 @@ module.exports.install = function (target, buildResults) {
98 97
             // This promise is always resolved, even if 'adb uninstall' fails to uninstall app
99 98
             // or the app doesn't installed at all, so no error catching needed.
100 99
             return Adb.uninstall(resolvedTarget.target, pkgName).then(function () {
101
-                return Adb.install(resolvedTarget.target, apk_path, {replace: true});
100
+                return Adb.install(resolvedTarget.target, apk_path, { replace: true });
102 101
             });
103 102
         }).then(function () {
104 103
             // unlock screen

+ 28
- 32
node_modules/cordova-android/bin/templates/cordova/lib/emulator.js View File

@@ -19,8 +19,6 @@
19 19
        under the License.
20 20
 */
21 21
 
22
-/* jshint sub:true */
23
-
24 22
 var android_versions = require('android-versions');
25 23
 var retry = require('./retry');
26 24
 var build = require('./build');
@@ -34,7 +32,6 @@ var shelljs = require('shelljs');
34 32
 var android_sdk = require('./android_sdk');
35 33
 var check_reqs = require('./check_reqs');
36 34
 
37
-var Q = require('q');
38 35
 var os = require('os');
39 36
 var fs = require('fs');
40 37
 var child_process = require('child_process');
@@ -170,15 +167,13 @@ module.exports.list_images_using_android = function () {
170 167
    }
171 168
  */
172 169
 module.exports.list_images = function () {
173
-    return Q.fcall(function () {
170
+    return Promise.resolve().then(function () {
174 171
         if (forgivingWhichSync('avdmanager')) {
175 172
             return module.exports.list_images_using_avdmanager();
176 173
         } else if (forgivingWhichSync('android')) {
177 174
             return module.exports.list_images_using_android();
178 175
         } else {
179
-            return Q().then(function () {
180
-                throw new CordovaError('Could not find either `android` or `avdmanager` on your $PATH! Are you sure the Android SDK is installed and available?');
181
-            });
176
+            return Promise.reject(new CordovaError('Could not find either `android` or `avdmanager` on your $PATH! Are you sure the Android SDK is installed and available?'));
182 177
         }
183 178
     }).then(function (avds) {
184 179
         // In case we're missing the Android OS version string from the target description, add it.
@@ -228,13 +223,13 @@ module.exports.best_image = function () {
228 223
 
229 224
 // Returns a promise.
230 225
 module.exports.list_started = function () {
231
-    return Adb.devices({emulators: true});
226
+    return Adb.devices({ emulators: true });
232 227
 };
233 228
 
234 229
 // Returns a promise.
235 230
 // TODO: we should remove this, there's a more robust method under android_sdk.js
236 231
 module.exports.list_targets = function () {
237
-    return superspawn.spawn('android', ['list', 'targets'], {cwd: os.tmpdir()}).then(function (output) {
232
+    return superspawn.spawn('android', ['list', 'targets'], { cwd: os.tmpdir() }).then(function (output) {
238 233
         var target_out = output.split('\n');
239 234
         var targets = [];
240 235
         for (var i = target_out.length; i >= 0; i--) {
@@ -277,8 +272,8 @@ module.exports.get_available_port = function () {
277 272
 module.exports.start = function (emulator_ID, boot_timeout) {
278 273
     var self = this;
279 274
 
280
-    return Q().then(function () {
281
-        if (emulator_ID) return Q(emulator_ID);
275
+    return Promise.resolve().then(function () {
276
+        if (emulator_ID) return Promise.resolve(emulator_ID);
282 277
 
283 278
         return self.best_image().then(function (best) {
284 279
             if (best && best.name) {
@@ -287,7 +282,7 @@ module.exports.start = function (emulator_ID, boot_timeout) {
287 282
             }
288 283
 
289 284
             var androidCmd = check_reqs.getAbsoluteAndroidCmd();
290
-            return Q.reject(new CordovaError('No emulator images (avds) found.\n' +
285
+            return Promise.reject(new CordovaError('No emulator images (avds) found.\n' +
291 286
                 '1. Download desired System Image by running: ' + androidCmd + ' sdk\n' +
292 287
                 '2. Create an AVD by running: ' + androidCmd + ' avd\n' +
293 288
                 'HINT: For a faster emulator, use an Intel System Image and install the HAXM device driver\n'));
@@ -308,7 +303,7 @@ module.exports.start = function (emulator_ID, boot_timeout) {
308 303
             return self.wait_for_emulator(port);
309 304
         });
310 305
     }).then(function (emulatorId) {
311
-        if (!emulatorId) { return Q.reject(new CordovaError('Failed to start emulator')); }
306
+        if (!emulatorId) { return Promise.reject(new CordovaError('Failed to start emulator')); }
312 307
 
313 308
         // wait for emulator to boot up
314 309
         process.stdout.write('Waiting for emulator to boot (this may take a while)...');
@@ -334,7 +329,7 @@ module.exports.start = function (emulator_ID, boot_timeout) {
334 329
  */
335 330
 module.exports.wait_for_emulator = function (port) {
336 331
     var self = this;
337
-    return Q().then(function () {
332
+    return Promise.resolve().then(function () {
338 333
         var emulator_id = 'emulator-' + port;
339 334
         return Adb.shell(emulator_id, 'getprop dev.bootcomplete').then(function (output) {
340 335
             if (output.indexOf('1') >= 0) {
@@ -345,7 +340,8 @@ module.exports.wait_for_emulator = function (port) {
345 340
             if ((error && error.message &&
346 341
             (error.message.indexOf('not found') > -1)) ||
347 342
             (error.message.indexOf('device offline') > -1) ||
348
-            (error.message.indexOf('device still connecting') > -1)) {
343
+            (error.message.indexOf('device still connecting') > -1) ||
344
+            (error.message.indexOf('device still authorizing') > -1)) {
349 345
                 // emulator not yet started, continue waiting
350 346
                 return self.wait_for_emulator(port);
351 347
             } else {
@@ -371,10 +367,13 @@ module.exports.wait_for_boot = function (emulator_id, time_remaining) {
371 367
         } else {
372 368
             process.stdout.write('.');
373 369
 
374
-            // Check at regular intervals
375
-            return Q.delay(time_remaining < CHECK_BOOTED_INTERVAL ? time_remaining : CHECK_BOOTED_INTERVAL).then(function () {
376
-                var updated_time = time_remaining >= 0 ? Math.max(time_remaining - CHECK_BOOTED_INTERVAL, 0) : time_remaining;
377
-                return self.wait_for_boot(emulator_id, updated_time);
370
+            return new Promise(resolve => {
371
+                const delay = time_remaining < CHECK_BOOTED_INTERVAL ? time_remaining : CHECK_BOOTED_INTERVAL;
372
+
373
+                setTimeout(() => {
374
+                    const updated_time = time_remaining >= 0 ? Math.max(time_remaining - CHECK_BOOTED_INTERVAL, 0) : time_remaining;
375
+                    resolve(self.wait_for_boot(emulator_id, updated_time));
376
+                }, delay);
378 377
             });
379 378
         }
380 379
     });
@@ -400,7 +399,7 @@ module.exports.create_image = function (name, target) {
400 399
             // TODO: This seems like another error case, even though it always happens.
401 400
             console.error('ERROR : Unable to create an avd emulator, no targets found.');
402 401
             console.error('Ensure you have targets available by running the "android" command');
403
-            return Q.reject();
402
+            return Promise.reject(new CordovaError());
404 403
         }, function (error) {
405 404
             console.error('ERROR : Failed to create emulator image : ');
406 405
             console.error(error);
@@ -411,17 +410,17 @@ module.exports.create_image = function (name, target) {
411 410
 module.exports.resolveTarget = function (target) {
412 411
     return this.list_started().then(function (emulator_list) {
413 412
         if (emulator_list.length < 1) {
414
-            return Q.reject('No running Android emulators found, please start an emulator before deploying your project.');
413
+            return Promise.reject(new CordovaError('No running Android emulators found, please start an emulator before deploying your project.'));
415 414
         }
416 415
 
417 416
         // default emulator
418 417
         target = target || emulator_list[0];
419 418
         if (emulator_list.indexOf(target) < 0) {
420
-            return Q.reject('Unable to find target \'' + target + '\'. Failed to deploy to emulator.');
419
+            return Promise.reject(new CordovaError('Unable to find target \'' + target + '\'. Failed to deploy to emulator.'));
421 420
         }
422 421
 
423 422
         return build.detectArchitecture(target).then(function (arch) {
424
-            return {target: target, arch: arch, isEmulator: true};
423
+            return { target: target, arch: arch, isEmulator: true };
425 424
         });
426 425
     });
427 426
 };
@@ -436,15 +435,12 @@ module.exports.install = function (givenTarget, buildResults) {
436 435
 
437 436
     var target;
438 437
     // We need to find the proper path to the Android Manifest
439
-    var manifestPath = path.join(__dirname, '..', '..', 'app', 'src', 'main', 'AndroidManifest.xml');
440
-    if (buildResults.buildMethod === 'gradle') {
441
-        manifestPath = path.join(__dirname, '../../AndroidManifest.xml');
442
-    }
443
-    var manifest = new AndroidManifest(manifestPath);
444
-    var pkgName = manifest.getPackageId();
438
+    const manifestPath = path.join(__dirname, '..', '..', 'app', 'src', 'main', 'AndroidManifest.xml');
439
+    const manifest = new AndroidManifest(manifestPath);
440
+    const pkgName = manifest.getPackageId();
445 441
 
446 442
     // resolve the target emulator
447
-    return Q().then(function () {
443
+    return Promise.resolve().then(function () {
448 444
         if (givenTarget && typeof givenTarget === 'object') {
449 445
             return givenTarget;
450 446
         } else {
@@ -459,7 +455,7 @@ module.exports.install = function (givenTarget, buildResults) {
459 455
     }).then(function () {
460 456
         // This promise is always resolved, even if 'adb uninstall' fails to uninstall app
461 457
         // or the app doesn't installed at all, so no error catching needed.
462
-        return Q.when().then(function () {
458
+        return Promise.resolve().then(function () {
463 459
 
464 460
             var apk_path = build.findBestApkForArchitecture(buildResults, target.arch);
465 461
             var execOptions = {
@@ -479,7 +475,7 @@ module.exports.install = function (givenTarget, buildResults) {
479 475
                 events.emit('verbose', 'Installing apk ' + apk + ' on ' + target + '...');
480 476
 
481 477
                 var command = 'adb -s ' + target + ' install -r "' + apk + '"';
482
-                return Q.promise(function (resolve, reject) {
478
+                return new Promise(function (resolve, reject) {
483 479
                     child_process.exec(command, opts, function (err, stdout, stderr) {
484 480
                         if (err) reject(new CordovaError('Error executing "' + command + '": ' + stderr));
485 481
                         // adb does not return an error code even if installation fails. Instead it puts a specific

+ 8
- 8
node_modules/cordova-android/bin/templates/cordova/lib/install-device View File

@@ -19,23 +19,23 @@
19 19
        under the License.
20 20
 */
21 21
 
22
-var device = require('./device'),
23
-    args   = process.argv;
22
+var device = require('./device');
23
+var args = process.argv;
24 24
 
25
-if(args.length > 2) {
25
+if (args.length > 2) {
26 26
     var install_target;
27
-    if (args[2].substring(0, 9) == '--target=') {
27
+    if (args[2].substring(0, 9) === '--target=') {
28 28
         install_target = args[2].substring(9, args[2].length);
29
-        device.install(install_target).done(null, function(err) {
29
+        device.install(install_target).catch(function (err) {
30 30
             console.error('ERROR: ' + err);
31 31
             process.exit(2);
32 32
         });
33
-     } else {
33
+    } else {
34 34
         console.error('ERROR : argument \'' + args[2] + '\' not recognized.');
35 35
         process.exit(2);
36
-     }
36
+    }
37 37
 } else {
38
-    device.install().done(null, function(err) {
38
+    device.install().catch(function (err) {
39 39
         console.error('ERROR: ' + err);
40 40
         process.exit(2);
41 41
     });

+ 7
- 7
node_modules/cordova-android/bin/templates/cordova/lib/install-emulator View File

@@ -19,20 +19,20 @@
19 19
        under the License.
20 20
 */
21 21
 
22
-var emulator = require('./emulator'),
23
-    args     = process.argv;
22
+var emulator = require('./emulator');
23
+var args = process.argv;
24 24
 
25 25
 var install_target;
26
-if(args.length > 2) {
27
-    if (args[2].substring(0, 9) == '--target=') {
26
+if (args.length > 2) {
27
+    if (args[2].substring(0, 9) === '--target=') {
28 28
         install_target = args[2].substring(9, args[2].length);
29
-     } else {
29
+    } else {
30 30
         console.error('ERROR : argument \'' + args[2] + '\' not recognized.');
31 31
         process.exit(2);
32
-     }
32
+    }
33 33
 }
34 34
 
35
-emulator.install(install_target).done(null, function(err) {
35
+emulator.install(install_target).catch(function (err) {
36 36
     console.error('ERROR: ' + err);
37 37
     process.exit(2);
38 38
 });

+ 4
- 4
node_modules/cordova-android/bin/templates/cordova/lib/list-devices View File

@@ -22,12 +22,12 @@
22 22
 var devices = require('./device');
23 23
 
24 24
 // Usage support for when args are given
25
-require('./check_reqs').check_android().then(function() {
26
-    devices.list().done(function(device_list) {
27
-        device_list && device_list.forEach(function(dev) {
25
+require('./check_reqs').check_android().then(function () {
26
+    devices.list().then(function (device_list) {
27
+        device_list && device_list.forEach(function (dev) {
28 28
             console.log(dev);
29 29
         });
30
-    }, function(err) {
30
+    }, function (err) {
31 31
         console.error('ERROR: ' + err);
32 32
         process.exit(2);
33 33
     });

+ 4
- 4
node_modules/cordova-android/bin/templates/cordova/lib/list-emulator-images View File

@@ -22,12 +22,12 @@
22 22
 var emulators = require('./emulator');
23 23
 
24 24
 // Usage support for when args are given
25
-require('./check_reqs').check_android().then(function() {
26
-    emulators.list_images().done(function(emulator_list) {
27
-        emulator_list && emulator_list.forEach(function(emu) {
25
+require('./check_reqs').check_android().then(function () {
26
+    emulators.list_images().then(function (emulator_list) {
27
+        emulator_list && emulator_list.forEach(function (emu) {
28 28
             console.log(emu.name);
29 29
         });
30
-    }, function(err) {
30
+    }, function (err) {
31 31
         console.error('ERROR: ' + err);
32 32
         process.exit(2);
33 33
     });

+ 4
- 4
node_modules/cordova-android/bin/templates/cordova/lib/list-started-emulators View File

@@ -22,12 +22,12 @@
22 22
 var emulators = require('./emulator');
23 23
 
24 24
 // Usage support for when args are given
25
-require('./check_reqs').check_android().then(function() {
26
-    emulators.list_started().done(function(emulator_list) {
27
-        emulator_list && emulator_list.forEach(function(emu) {
25
+require('./check_reqs').check_android().then(function () {
26
+    emulators.list_started().then(function (emulator_list) {
27
+        emulator_list && emulator_list.forEach(function (emu) {
28 28
             console.log(emu);
29 29
         });
30
-    }, function(err) {
30
+    }, function (err) {
31 31
         console.error('ERROR: ' + err);
32 32
         process.exit(2);
33 33
     });

+ 1
- 1
node_modules/cordova-android/bin/templates/cordova/lib/log.js View File

@@ -31,7 +31,7 @@ var ROOT = path.join(__dirname, '..', '..');
31 31
  */
32 32
 module.exports.run = function () {
33 33
     var d = Q.defer();
34
-    var adb = child_process.spawn('adb', ['logcat'], {cwd: os.tmpdir()});
34
+    var adb = child_process.spawn('adb', ['logcat'], { cwd: os.tmpdir() });
35 35
 
36 36
     adb.stdout.on('data', function (data) {
37 37
         var lines = data ? data.toString().split('\n') : [];

+ 2
- 5
node_modules/cordova-android/bin/templates/cordova/lib/plugin-build.gradle View File

@@ -20,9 +20,7 @@
20 20
 
21 21
 buildscript {
22 22
     repositories {
23
-        maven {
24
-            url "https://maven.google.com"
25
-        }
23
+        google()
26 24
         jcenter()
27 25
     }
28 26
 
@@ -38,7 +36,7 @@ buildscript {
38 36
 apply plugin: 'com.android.library'
39 37
 
40 38
 dependencies {
41
-    compile fileTree(dir: 'libs', include: '*.jar')
39
+    implementation fileTree(dir: 'libs', include: '*.jar')
42 40
     debugCompile project(path: ":CordovaLib", configuration: "debug")
43 41
     releaseCompile project(path: ":CordovaLib", configuration: "release")
44 42
 }
@@ -46,7 +44,6 @@ dependencies {
46 44
 android {
47 45
     compileSdkVersion cdvCompileSdkVersion
48 46
     buildToolsVersion cdvBuildToolsVersion
49
-    publishNonDefault true
50 47
 
51 48
     compileOptions {
52 49
         sourceCompatibility JavaVersion.VERSION_1_6

+ 33
- 44
node_modules/cordova-android/bin/templates/cordova/lib/pluginHandlers.js View File

@@ -14,8 +14,6 @@
14 14
  *
15 15
 */
16 16
 
17
-/* jshint unused: vars */
18
-
19 17
 var fs = require('fs');
20 18
 var path = require('path');
21 19
 var shell = require('shelljs');
@@ -28,14 +26,7 @@ var handlers = {
28 26
             if (!obj.src) throw new CordovaError(generateAttributeError('src', 'source-file', plugin.id));
29 27
             if (!obj.targetDir) throw new CordovaError(generateAttributeError('target-dir', 'source-file', plugin.id));
30 28
 
31
-            var dest = path.join(obj.targetDir, path.basename(obj.src));
32
-
33
-            // TODO: This code needs to be replaced, since the core plugins need to be re-mapped to a different location in
34
-            // a later plugins release.  This is for legacy plugins to work with Cordova.
35
-
36
-            if (options && options.android_studio === true) {
37
-                dest = getInstallDestination(obj);
38
-            }
29
+            var dest = getInstallDestination(obj);
39 30
 
40 31
             if (options && options.force) {
41 32
                 copyFile(plugin.dir, obj.src, project.projectDir, dest, !!(options && options.link));
@@ -44,11 +35,7 @@ var handlers = {
44 35
             }
45 36
         },
46 37
         uninstall: function (obj, plugin, project, options) {
47
-            var dest = path.join(obj.targetDir, path.basename(obj.src));
48
-
49
-            if (options && options.android_studio === true) {
50
-                dest = getInstallDestination(obj);
51
-            }
38
+            var dest = getInstallDestination(obj);
52 39
 
53 40
             // TODO: Add Koltin extension to uninstall, since they are handled like Java files
54 41
             if (obj.src.endsWith('java')) {
@@ -61,33 +48,21 @@ var handlers = {
61 48
     },
62 49
     'lib-file': {
63 50
         install: function (obj, plugin, project, options) {
64
-            var dest = path.join('libs', path.basename(obj.src));
65
-            if (options && options.android_studio === true) {
66
-                dest = path.join('app/libs', path.basename(obj.src));
67
-            }
51
+            var dest = path.join('app/libs', path.basename(obj.src));
68 52
             copyFile(plugin.dir, obj.src, project.projectDir, dest, !!(options && options.link));
69 53
         },
70 54
         uninstall: function (obj, plugin, project, options) {
71
-            var dest = path.join('libs', path.basename(obj.src));
72
-            if (options && options.android_studio === true) {
73
-                dest = path.join('app/libs', path.basename(obj.src));
74
-            }
55
+            var dest = path.join('app/libs', path.basename(obj.src));
75 56
             removeFile(project.projectDir, dest);
76 57
         }
77 58
     },
78 59
     'resource-file': {
79 60
         install: function (obj, plugin, project, options) {
80
-            var dest = path.normalize(obj.target);
81
-            if (options && options.android_studio === true) {
82
-                dest = path.join('app/src/main', dest);
83
-            }
61
+            var dest = path.join('app', 'src', 'main', obj.target);
84 62
             copyFile(plugin.dir, obj.src, project.projectDir, dest, !!(options && options.link));
85 63
         },
86 64
         uninstall: function (obj, plugin, project, options) {
87
-            var dest = path.normalize(obj.target);
88
-            if (options && options.android_studio === true) {
89
-                dest = path.join('app/src/main', dest);
90
-            }
65
+            var dest = path.join('app', 'src', 'main', obj.target);
91 66
             removeFile(project.projectDir, dest);
92 67
         }
93 68
     },
@@ -319,27 +294,41 @@ function generateAttributeError (attribute, element, id) {
319 294
 
320 295
 function getInstallDestination (obj) {
321 296
     var APP_MAIN_PREFIX = 'app/src/main';
297
+    var PATH_SEPARATOR = '/';
322 298
 
323
-    if (obj.targetDir.startsWith('app')) {
299
+    var PATH_SEP_MATCH = '\\' + PATH_SEPARATOR;
300
+    var PATH_SEP_OR_EOL_MATCH = '(\\' + PATH_SEPARATOR + '|$)';
301
+
302
+    var appReg = new RegExp('^app' + PATH_SEP_OR_EOL_MATCH);
303
+    var libsReg = new RegExp('^libs' + PATH_SEP_OR_EOL_MATCH);
304
+    var srcReg = new RegExp('^src' + PATH_SEP_OR_EOL_MATCH);
305
+    var srcMainReg = new RegExp('^src' + PATH_SEP_MATCH + 'main' + PATH_SEP_OR_EOL_MATCH);
306
+
307
+    if (appReg.test(obj.targetDir)) {
324 308
         // If any source file is using the new app directory structure,
325 309
         // don't penalize it
326 310
         return path.join(obj.targetDir, path.basename(obj.src));
327
-    } else if (obj.src.endsWith('.java')) {
328
-        return path.join(APP_MAIN_PREFIX, 'java', obj.targetDir.substring(4), path.basename(obj.src));
329
-    } else if (obj.src.endsWith('.aidl')) {
330
-        return path.join(APP_MAIN_PREFIX, 'aidl', obj.targetDir.substring(4), path.basename(obj.src));
331
-    } else if (obj.targetDir.includes('libs')) {
332
-        if (obj.src.endsWith('.so')) {
333
-            return path.join(APP_MAIN_PREFIX, 'jniLibs', obj.targetDir.substring(5), path.basename(obj.src));
334
-        } else {
311
+    } else {
312
+        // Plugin using deprecated target directory structure (GH-580)
313
+        if (obj.src.endsWith('.java')) {
314
+            return path.join(APP_MAIN_PREFIX, 'java', obj.targetDir.replace(srcReg, ''),
315
+                path.basename(obj.src));
316
+        } else if (obj.src.endsWith('.aidl')) {
317
+            return path.join(APP_MAIN_PREFIX, 'aidl', obj.targetDir.replace(srcReg, ''),
318
+                path.basename(obj.src));
319
+        } else if (libsReg.test(obj.targetDir)) {
320
+            if (obj.src.endsWith('.so')) {
321
+                return path.join(APP_MAIN_PREFIX, 'jniLibs', obj.targetDir.replace(libsReg, ''),
322
+                    path.basename(obj.src));
323
+            } else {
324
+                return path.join('app', obj.targetDir, path.basename(obj.src));
325
+            }
326
+        } else if (srcMainReg.test(obj.targetDir)) {
335 327
             return path.join('app', obj.targetDir, path.basename(obj.src));
336 328
         }
337
-    } else if (obj.targetDir.includes('src/main')) {
338
-        return path.join('app', obj.targetDir, path.basename(obj.src));
339
-    } else {
329
+
340 330
         // For all other source files not using the new app directory structure,
341 331
         // add 'app/src/main' to the targetDir
342 332
         return path.join(APP_MAIN_PREFIX, obj.targetDir, path.basename(obj.src));
343 333
     }
344
-
345 334
 }

+ 255
- 34
node_modules/cordova-android/bin/templates/cordova/lib/prepare.js View File

@@ -33,6 +33,8 @@ var PlatformJson = require('cordova-common').PlatformJson;
33 33
 var PlatformMunger = require('cordova-common').ConfigChanges.PlatformMunger;
34 34
 var PluginInfoProvider = require('cordova-common').PluginInfoProvider;
35 35
 
36
+const GradlePropertiesParser = require('./config/GradlePropertiesParser');
37
+
36 38
 module.exports.prepare = function (cordovaProject, options) {
37 39
     var self = this;
38 40
 
@@ -41,6 +43,15 @@ module.exports.prepare = function (cordovaProject, options) {
41 43
 
42 44
     this._config = updateConfigFilesFrom(cordovaProject.projectConfig, munger, this.locations);
43 45
 
46
+    // Get the min SDK version from config.xml
47
+    const minSdkVersion = this._config.getPreference('android-minSdkVersion', 'android');
48
+
49
+    let gradlePropertiesUserConfig = {};
50
+    if (minSdkVersion) gradlePropertiesUserConfig.cdvMinSdkVersion = minSdkVersion;
51
+
52
+    let gradlePropertiesParser = new GradlePropertiesParser(this.locations.root);
53
+    gradlePropertiesParser.configure(gradlePropertiesUserConfig);
54
+
44 55
     // Update own www dir with project's www assets and plugins' assets and js-files
45 56
     return Q.when(updateWww(cordovaProject, this.locations)).then(function () {
46 57
         // update project according to config.xml changes.
@@ -178,7 +189,7 @@ function updateProjectAccordingTo (platformConfig, locations) {
178 189
         strings.find('string[@name="launcher_name"]').text = shortName.replace(/\'/g, '\\\'');
179 190
     }
180 191
 
181
-    fs.writeFileSync(locations.strings, strings.write({indent: 4}), 'utf-8');
192
+    fs.writeFileSync(locations.strings, strings.write({ indent: 4 }), 'utf-8');
182 193
     events.emit('verbose', 'Wrote out android application name "' + name + '" to ' + locations.strings);
183 194
 
184 195
     // Java packages cannot support dashes
@@ -265,6 +276,14 @@ function getImageResourcePath (resourcesDir, type, density, name, sourceName) {
265 276
     return resourcePath;
266 277
 }
267 278
 
279
+function getAdaptiveImageResourcePath (resourcesDir, type, density, name, sourceName) {
280
+    if (/\.9\.png$/.test(sourceName)) {
281
+        name = name.replace(/\.png$/, '.9.png');
282
+    }
283
+    var resourcePath = path.join(resourcesDir, (density ? type + '-' + density + '-v26' : type), name);
284
+    return resourcePath;
285
+}
286
+
268 287
 function updateSplashes (cordovaProject, platformResourcesDir) {
269 288
     var resources = cordovaProject.projectConfig.getSplashScreens('android');
270 289
 
@@ -314,20 +333,197 @@ function cleanSplashes (projectRoot, projectConfig, platformResourcesDir) {
314 333
 }
315