From 00134cf9f3148335d17aa47dcfed589ca1460fda Mon Sep 17 00:00:00 2001 From: Darshan-Chauhan Date: Wed, 12 Sep 2018 15:34:00 +0530 Subject: [PATCH 01/18] Incorrect default sdk version issue fix (PR #495) --- bin/templates/project/app/build.gradle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/templates/project/app/build.gradle b/bin/templates/project/app/build.gradle index b47fdf94..5795130a 100644 --- a/bin/templates/project/app/build.gradle +++ b/bin/templates/project/app/build.gradle @@ -69,7 +69,7 @@ ext { if (!project.hasProperty('cdvBuildMultipleApks')) { cdvBuildMultipleApks = null } - // Whether to append a 0 "abi digit" to versionCode when only a single APK is build + // Whether to append a 0 "abi digit" to versionCode when only a single APK is build if (!project.hasProperty('cdvVersionCodeForceAbiDigit')) { cdvVersionCodeForceAbiDigit = null } @@ -117,7 +117,7 @@ if (ext.cdvReleaseSigningPropertiesFile == null && file('../release-signing.prop // Cast to appropriate types. ext.cdvBuildMultipleApks = cdvBuildMultipleApks == null ? false : cdvBuildMultipleApks.toBoolean(); ext.cdvVersionCodeForceAbiDigit = cdvVersionCodeForceAbiDigit == null ? false : cdvVersionCodeForceAbiDigit.toBoolean(); -ext.cdvMinSdkVersion = cdvMinSdkVersion == null ? null : defaultMinSdkVersion +ext.cdvMinSdkVersion = cdvMinSdkVersion == null ? defaultMinSdkVersion : cdvMinSdkVersion ext.cdvVersionCode = cdvVersionCode == null ? null : Integer.parseInt('' + cdvVersionCode) def computeBuildTargetName(debugBuild) { @@ -175,7 +175,7 @@ android { buildToolsVersion cdvBuildToolsVersion //This code exists for Crosswalk and other Native APIs. - //By default, we multiply the existing version code in the Android Manifest by 10 and + //By default, we multiply the existing version code in the Android Manifest by 10 and //add a number for each architecture. If you are not using Crosswalk or SQLite, you can //ignore this chunk of code, and your version codes will be respected. From dbc99e8f4ccbc190fc21d8a12b74320da36ceef0 Mon Sep 17 00:00:00 2001 From: Chris Brody Date: Wed, 12 Sep 2018 07:52:11 -0400 Subject: [PATCH 02/18] Update comments (#496) as followup to GH-495 --- bin/templates/project/app/build.gradle | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bin/templates/project/app/build.gradle b/bin/templates/project/app/build.gradle index 5795130a..e82c6264 100644 --- a/bin/templates/project/app/build.gradle +++ b/bin/templates/project/app/build.gradle @@ -174,10 +174,11 @@ android { compileSdkVersion cdvCompileSdkVersion buildToolsVersion cdvBuildToolsVersion - //This code exists for Crosswalk and other Native APIs. - //By default, we multiply the existing version code in the Android Manifest by 10 and - //add a number for each architecture. If you are not using Crosswalk or SQLite, you can - //ignore this chunk of code, and your version codes will be respected. + // This code exists for Crosswalk and other Native APIs. + // By default, we multiply the existing version code in the + // Android Manifest by 10 and add a number for each architecture. + // If you are not using Crosswalk or SQLite, you can + // ignore this chunk of code, and your version codes will be respected. if (Boolean.valueOf(cdvBuildMultipleApks)) { flavorDimensions "default" From 9f6c332b8c5644828b878e831c1e503cff556e4d Mon Sep 17 00:00:00 2001 From: Chris Brody Date: Mon, 12 Nov 2018 12:06:45 -0500 Subject: [PATCH 03/18] Remove obsolete check for JellyBean (GH-534) (#544) to work properly on Android Pie was introduced in dc0bfeb0c (CB-11828) Resolves #534 Co-authored-by: Co-authored-by: Christopher J. Brody --- cordova-js-src/exec.js | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/cordova-js-src/exec.js b/cordova-js-src/exec.js index f73d87a1..39e8c97e 100644 --- a/cordova-js-src/exec.js +++ b/cordova-js-src/exec.js @@ -109,17 +109,6 @@ function androidExec(success, fail, service, action, args) { } androidExec.init = function() { - //CB-11828 - //This failsafe checks the version of Android and if it's Jellybean, it switches it to - //using the Online Event bridge for communicating from Native to JS - // - //It's ugly, but it's necessary. - var check = navigator.userAgent.toLowerCase().match(/android\s[0-9].[0-9]/); - var version_code = check && check[0].match(/4.[0-3].*/); - if (version_code != null && nativeToJsBridgeMode == nativeToJsModes.EVAL_BRIDGE) { - nativeToJsBridgeMode = nativeToJsModes.ONLINE_EVENT; - } - bridgeSecret = +prompt('', 'gap_init:' + nativeToJsBridgeMode); channel.onNativeReady.fire(); }; From c0e9f2515046b8f927dea4b0646d6dd3acfd1c40 Mon Sep 17 00:00:00 2001 From: Kyle Kirbatski Date: Thu, 8 Nov 2018 12:23:29 -0600 Subject: [PATCH 04/18] =?UTF-8?q?Add=20a=20unit=20test=20to=20test=20sourc?= =?UTF-8?q?e-file=20target-dir=20/app/src/main/=E2=80=A6=20(PR=20#542)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/fixtures/org.test.plugins.dummyplugin/plugin.xml | 2 ++ .../src/android/DummyPlugin2.java | 1 + spec/unit/pluginHandlers/handlers.spec.js | 6 ++++++ 3 files changed, 9 insertions(+) create mode 100644 spec/fixtures/org.test.plugins.dummyplugin/src/android/DummyPlugin2.java diff --git a/spec/fixtures/org.test.plugins.dummyplugin/plugin.xml b/spec/fixtures/org.test.plugins.dummyplugin/plugin.xml index a40df2b2..5451ef8d 100644 --- a/spec/fixtures/org.test.plugins.dummyplugin/plugin.xml +++ b/spec/fixtures/org.test.plugins.dummyplugin/plugin.xml @@ -70,6 +70,8 @@ + diff --git a/spec/fixtures/org.test.plugins.dummyplugin/src/android/DummyPlugin2.java b/spec/fixtures/org.test.plugins.dummyplugin/src/android/DummyPlugin2.java new file mode 100644 index 00000000..c2dd0f73 --- /dev/null +++ b/spec/fixtures/org.test.plugins.dummyplugin/src/android/DummyPlugin2.java @@ -0,0 +1 @@ +./org.test.plugins.dummyplugin/src/android/DummyPlugin2.java diff --git a/spec/unit/pluginHandlers/handlers.spec.js b/spec/unit/pluginHandlers/handlers.spec.js index edc8f43b..19abab8c 100644 --- a/spec/unit/pluginHandlers/handlers.spec.js +++ b/spec/unit/pluginHandlers/handlers.spec.js @@ -108,6 +108,12 @@ describe('android project handler', function () { android['source-file'].install(valid_source[0], dummyPluginInfo, dummyProject); }).toThrow(new Error('"' + target + '" already exists!')); }); + + it('Test#007 : should allow installing sources using proper path', function () { + android['source-file'].install(valid_source[1], dummyPluginInfo, dummyProject, {android_studio: true}); + expect(copyFileSpy) + .toHaveBeenCalledWith(dummyplugin, 'src/android/DummyPlugin2.java', temp, path.join('app/src/main/src/com/phonegap/plugins/dummyplugin/DummyPlugin2.java'), false); + }); }); describe('of elements', function () { From 55f2986b85127575f106411cb254720444e12840 Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Sun, 11 Nov 2018 13:36:31 -0500 Subject: [PATCH 05/18] unit test uninstall of with app dest (PR #542) for Java source only (GH-539) Co-Authored-By: Christopher J. Brody Co-Authored-By: Kyle Kirbatski --- spec/unit/pluginHandlers/handlers.spec.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/spec/unit/pluginHandlers/handlers.spec.js b/spec/unit/pluginHandlers/handlers.spec.js index 19abab8c..206de56e 100644 --- a/spec/unit/pluginHandlers/handlers.spec.js +++ b/spec/unit/pluginHandlers/handlers.spec.js @@ -263,6 +263,10 @@ describe('android project handler', function () { }); }); + // TODO: + // - merge tests of elements into single describe block + // (with proper beforeEach/afterEach) + // - renumber the tests after Test#019 describe('of elements', function () { it('Test#019 : should remove stuff by calling common.deleteJava for Android Studio projects', function () { android['source-file'].install(valid_source[0], dummyPluginInfo, dummyProject, {android_studio: true}); @@ -271,6 +275,14 @@ describe('android project handler', function () { }); }); + describe('of element, with specific app target-dir', function () { + it('Test#019a : should remove stuff by calling common.deleteJava for Android Studio projects, with specific app target-dir', function () { + android['source-file'].install(valid_source[1], dummyPluginInfo, dummyProject, {android_studio: true}); + android['source-file'].uninstall(valid_source[1], dummyPluginInfo, dummyProject, {android_studio: true}); + expect(deleteJavaSpy).toHaveBeenCalledWith(temp, path.join('app/src/main/src/com/phonegap/plugins/dummyplugin/DummyPlugin2.java')); + }); + }); + describe('of elements', function () { var someString = jasmine.any(String); From 4d151d3057908417088543d9ce45f1f972f95e41 Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Sun, 11 Nov 2018 15:07:01 -0500 Subject: [PATCH 06/18] GH-539 fix destination path fallback (PR #542) Fallback to old path mapping if no Android Studio path mapping exists (with slight difference on 7.1.x branch) Co-authored-by: Christopher J. Brody Co-authored-by: Kyle Kirbatski --- bin/templates/cordova/lib/pluginHandlers.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bin/templates/cordova/lib/pluginHandlers.js b/bin/templates/cordova/lib/pluginHandlers.js index a3ebed0e..e78e3ee4 100644 --- a/bin/templates/cordova/lib/pluginHandlers.js +++ b/bin/templates/cordova/lib/pluginHandlers.js @@ -34,7 +34,7 @@ var handlers = { // a later plugins release. This is for legacy plugins to work with Cordova. if (options && options.android_studio === true) { - dest = studioPathRemap(obj); + dest = getInstallDestination(obj); } if (options && options.force) { @@ -47,7 +47,7 @@ var handlers = { var dest = path.join(obj.targetDir, path.basename(obj.src)); if (options && options.android_studio === true) { - dest = studioPathRemap(obj); + dest = getInstallDestination(obj); } // TODO: Add Koltin extension to uninstall, since they are handled like Java files @@ -317,6 +317,11 @@ function generateAttributeError (attribute, element, id) { return 'Required attribute "' + attribute + '" not specified in <' + element + '> element from plugin: ' + id; } +function getInstallDestination (obj) { + return studioPathRemap(obj) || + path.join(obj.targetDir, path.basename(obj.src)); +} + function studioPathRemap (obj) { // If a Java file is using the new directory structure, don't penalize it if (!obj.targetDir.includes('app/src/main')) { From f8584c63e6df858470de692791e7f993f2706df6 Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Fri, 9 Nov 2018 14:43:47 -0500 Subject: [PATCH 07/18] unit test source-file with custom lib target-dir (PR #542) for JAR and AAR (GH-540) Co-Authored-By: Kyle Kirbatski Co-Authored-By: Christopher J. Brody Co-Authored-By: @afdev82 (Antonio Facciolo) --- .../org.test.plugins.dummyplugin/plugin.xml | 4 ++++ .../src/android/TestAar.aar | 1 + spec/unit/pluginHandlers/handlers.spec.js | 13 +++++++++++++ 3 files changed, 18 insertions(+) create mode 100644 spec/fixtures/org.test.plugins.dummyplugin/src/android/TestAar.aar diff --git a/spec/fixtures/org.test.plugins.dummyplugin/plugin.xml b/spec/fixtures/org.test.plugins.dummyplugin/plugin.xml index 5451ef8d..b299b645 100644 --- a/spec/fixtures/org.test.plugins.dummyplugin/plugin.xml +++ b/spec/fixtures/org.test.plugins.dummyplugin/plugin.xml @@ -72,6 +72,10 @@ target-dir="src/com/phonegap/plugins/dummyplugin" /> + + diff --git a/spec/fixtures/org.test.plugins.dummyplugin/src/android/TestAar.aar b/spec/fixtures/org.test.plugins.dummyplugin/src/android/TestAar.aar new file mode 100644 index 00000000..ce401543 --- /dev/null +++ b/spec/fixtures/org.test.plugins.dummyplugin/src/android/TestAar.aar @@ -0,0 +1 @@ +./org.test.plugins.dummyplugin/src/android/TestAar.aar diff --git a/spec/unit/pluginHandlers/handlers.spec.js b/spec/unit/pluginHandlers/handlers.spec.js index 206de56e..1baf3977 100644 --- a/spec/unit/pluginHandlers/handlers.spec.js +++ b/spec/unit/pluginHandlers/handlers.spec.js @@ -114,6 +114,19 @@ describe('android project handler', function () { expect(copyFileSpy) .toHaveBeenCalledWith(dummyplugin, 'src/android/DummyPlugin2.java', temp, path.join('app/src/main/src/com/phonegap/plugins/dummyplugin/DummyPlugin2.java'), false); }); + + // TODO: renumber these tests and other tests below + it('Test#007a : should allow installing lib file from sources using proper path', function () { + android['source-file'].install(valid_source[2], dummyPluginInfo, dummyProject, {android_studio: true}); + expect(copyFileSpy) + .toHaveBeenCalledWith(dummyplugin, 'src/android/TestLib.jar', temp, path.join('app/libs/TestLib.jar'), false); + }); + + it('Test#007b : should allow installing aar file from sources using proper path', function () { + android['source-file'].install(valid_source[3], dummyPluginInfo, dummyProject, {android_studio: true}); + expect(copyFileSpy) + .toHaveBeenCalledWith(dummyplugin, 'src/android/TestAar.aar', temp, path.join('app/libs/TestAar.aar'), false); + }); }); describe('of elements', function () { From 951ff5552edc6fc8a7e64913d9a136d5b49ed0d8 Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Sun, 11 Nov 2018 13:36:31 -0500 Subject: [PATCH 08/18] unit test uninstall of with app dest (PR #542) for Java source, JAR, and AAR Co-authored-by: Christopher J. Brody Co-authored-by: Kyle Kirbatski Co-authored-by: Antonio Facciolo --- spec/unit/pluginHandlers/handlers.spec.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/spec/unit/pluginHandlers/handlers.spec.js b/spec/unit/pluginHandlers/handlers.spec.js index 1baf3977..c6a6a7fb 100644 --- a/spec/unit/pluginHandlers/handlers.spec.js +++ b/spec/unit/pluginHandlers/handlers.spec.js @@ -296,6 +296,22 @@ describe('android project handler', function () { }); }); + describe('of element, with JAR in specific app target-dir', function () { + it('Test#019b : should remove stuff by calling common.deleteJava for Android Studio projects, with JAR into specific app target-dir', function () { + android['source-file'].install(valid_source[2], dummyPluginInfo, dummyProject, {android_studio: true}); + android['source-file'].uninstall(valid_source[2], dummyPluginInfo, dummyProject, {android_studio: true}); + expect(removeFileSpy).toHaveBeenCalledWith(temp, path.join('app/libs/TestLib.jar')); + }); + }); + + describe('of element, with AAR in specific app target-dir', function () { + it('Test#019c : should remove stuff by calling common.deleteJava for Android Studio projects, with JAR into specific app target-dir', function () { + android['source-file'].install(valid_source[3], dummyPluginInfo, dummyProject, {android_studio: true}); + android['source-file'].uninstall(valid_source[3], dummyPluginInfo, dummyProject, {android_studio: true}); + expect(removeFileSpy).toHaveBeenCalledWith(temp, path.join('app/libs/TestAar.aar')); + }); + }); + describe('of elements', function () { var someString = jasmine.any(String); From 717d768cec1145f6512f9ef94dd54e22a7c93a58 Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Sun, 11 Nov 2018 15:26:04 -0500 Subject: [PATCH 09/18] GH-540 fix for source-file with app target-dir (PR #542) --- bin/templates/cordova/lib/pluginHandlers.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/templates/cordova/lib/pluginHandlers.js b/bin/templates/cordova/lib/pluginHandlers.js index e78e3ee4..18f7996a 100644 --- a/bin/templates/cordova/lib/pluginHandlers.js +++ b/bin/templates/cordova/lib/pluginHandlers.js @@ -323,8 +323,9 @@ function getInstallDestination (obj) { } function studioPathRemap (obj) { - // If a Java file is using the new directory structure, don't penalize it - if (!obj.targetDir.includes('app/src/main')) { + // If any source file is using the app new directory structure, + // don't penalize it + if (!obj.targetDir.includes('app')) { if (obj.src.endsWith('.java')) { return path.join('app/src/main/java', obj.targetDir.substring(4), path.basename(obj.src)); } else { From 5222a0f6059d65fd2fbf48ee018e16165f11937a Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Mon, 12 Nov 2018 21:42:31 -0500 Subject: [PATCH 10/18] Fix tests of plugin files with new app dir scheme (PR #542) (new app target-dir scheme) --- spec/unit/pluginHandlers/handlers.spec.js | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/spec/unit/pluginHandlers/handlers.spec.js b/spec/unit/pluginHandlers/handlers.spec.js index c6a6a7fb..60a69144 100644 --- a/spec/unit/pluginHandlers/handlers.spec.js +++ b/spec/unit/pluginHandlers/handlers.spec.js @@ -109,20 +109,20 @@ describe('android project handler', function () { }).toThrow(new Error('"' + target + '" already exists!')); }); - it('Test#007 : should allow installing sources using proper path', function () { + // TODO: renumber these tests and other tests below + it('Test#00a6 : should allow installing sources with new app target-dir scheme', function () { android['source-file'].install(valid_source[1], dummyPluginInfo, dummyProject, {android_studio: true}); expect(copyFileSpy) .toHaveBeenCalledWith(dummyplugin, 'src/android/DummyPlugin2.java', temp, path.join('app/src/main/src/com/phonegap/plugins/dummyplugin/DummyPlugin2.java'), false); }); - // TODO: renumber these tests and other tests below - it('Test#007a : should allow installing lib file from sources using proper path', function () { + it('Test#006b : should allow installing jar lib file from sources with new app target-dir scheme', function () { android['source-file'].install(valid_source[2], dummyPluginInfo, dummyProject, {android_studio: true}); expect(copyFileSpy) .toHaveBeenCalledWith(dummyplugin, 'src/android/TestLib.jar', temp, path.join('app/libs/TestLib.jar'), false); }); - it('Test#007b : should allow installing aar file from sources using proper path', function () { + it('Test#006c : should allow installing aar lib file from sources with new app target-dir scheme', function () { android['source-file'].install(valid_source[3], dummyPluginInfo, dummyProject, {android_studio: true}); expect(copyFileSpy) .toHaveBeenCalledWith(dummyplugin, 'src/android/TestAar.aar', temp, path.join('app/libs/TestAar.aar'), false); @@ -276,36 +276,26 @@ describe('android project handler', function () { }); }); - // TODO: - // - merge tests of elements into single describe block - // (with proper beforeEach/afterEach) - // - renumber the tests after Test#019 describe('of elements', function () { it('Test#019 : should remove stuff by calling common.deleteJava for Android Studio projects', function () { android['source-file'].install(valid_source[0], dummyPluginInfo, dummyProject, {android_studio: true}); android['source-file'].uninstall(valid_source[0], dummyPluginInfo, dummyProject, {android_studio: true}); expect(deleteJavaSpy).toHaveBeenCalledWith(temp, path.join('app/src/main/java/com/phonegap/plugins/dummyplugin/DummyPlugin.java')); }); - }); - describe('of element, with specific app target-dir', function () { it('Test#019a : should remove stuff by calling common.deleteJava for Android Studio projects, with specific app target-dir', function () { android['source-file'].install(valid_source[1], dummyPluginInfo, dummyProject, {android_studio: true}); android['source-file'].uninstall(valid_source[1], dummyPluginInfo, dummyProject, {android_studio: true}); expect(deleteJavaSpy).toHaveBeenCalledWith(temp, path.join('app/src/main/src/com/phonegap/plugins/dummyplugin/DummyPlugin2.java')); }); - }); - describe('of element, with JAR in specific app target-dir', function () { - it('Test#019b : should remove stuff by calling common.deleteJava for Android Studio projects, with JAR into specific app target-dir', function () { + it('Test#019b : should remove stuff by calling common.removeFile for Android Studio projects, of jar with new app target-dir scheme', function () { android['source-file'].install(valid_source[2], dummyPluginInfo, dummyProject, {android_studio: true}); android['source-file'].uninstall(valid_source[2], dummyPluginInfo, dummyProject, {android_studio: true}); expect(removeFileSpy).toHaveBeenCalledWith(temp, path.join('app/libs/TestLib.jar')); }); - }); - describe('of element, with AAR in specific app target-dir', function () { - it('Test#019c : should remove stuff by calling common.deleteJava for Android Studio projects, with JAR into specific app target-dir', function () { + it('Test#019c : should remove stuff by calling common.removeFile for Android Studio projects, of aar with new app target-dir scheme', function () { android['source-file'].install(valid_source[3], dummyPluginInfo, dummyProject, {android_studio: true}); android['source-file'].uninstall(valid_source[3], dummyPluginInfo, dummyProject, {android_studio: true}); expect(removeFileSpy).toHaveBeenCalledWith(temp, path.join('app/libs/TestAar.aar')); From e3468c66a374ac4a05940ccb3b0cbf1e5b56b193 Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Mon, 12 Nov 2018 21:50:20 -0500 Subject: [PATCH 11/18] Check target-dir mapping of plugin xml source file (PR #550) Possibly related to: CB-13830: Add handlers for plugins that use non-Java source files, such as Camera --- .../org.test.plugins.dummyplugin/plugin.xml | 1 + .../src/android/mysettings.xml | 1 + spec/unit/pluginHandlers/handlers.spec.js | 13 +++++++++++++ 3 files changed, 15 insertions(+) create mode 100644 spec/fixtures/org.test.plugins.dummyplugin/src/android/mysettings.xml diff --git a/spec/fixtures/org.test.plugins.dummyplugin/plugin.xml b/spec/fixtures/org.test.plugins.dummyplugin/plugin.xml index b299b645..5cd28720 100644 --- a/spec/fixtures/org.test.plugins.dummyplugin/plugin.xml +++ b/spec/fixtures/org.test.plugins.dummyplugin/plugin.xml @@ -76,6 +76,7 @@ target-dir="app/libs" /> + diff --git a/spec/fixtures/org.test.plugins.dummyplugin/src/android/mysettings.xml b/spec/fixtures/org.test.plugins.dummyplugin/src/android/mysettings.xml new file mode 100644 index 00000000..421376db --- /dev/null +++ b/spec/fixtures/org.test.plugins.dummyplugin/src/android/mysettings.xml @@ -0,0 +1 @@ +dummy diff --git a/spec/unit/pluginHandlers/handlers.spec.js b/spec/unit/pluginHandlers/handlers.spec.js index 60a69144..6d90bd02 100644 --- a/spec/unit/pluginHandlers/handlers.spec.js +++ b/spec/unit/pluginHandlers/handlers.spec.js @@ -127,6 +127,13 @@ describe('android project handler', function () { expect(copyFileSpy) .toHaveBeenCalledWith(dummyplugin, 'src/android/TestAar.aar', temp, path.join('app/libs/TestAar.aar'), false); }); + + it('Test#006d : should allow installing xml file from sources with old target-dir scheme', function () { + android['source-file'].install(valid_source[4], dummyPluginInfo, dummyProject, {android_studio: true}); + expect(copyFileSpy).toHaveBeenCalledWith(dummyplugin, + 'src/android/mysettings.xml', temp, + path.join('app/src/main/res/xml/mysettings.xml'), false); + }); }); describe('of elements', function () { @@ -300,6 +307,12 @@ describe('android project handler', function () { android['source-file'].uninstall(valid_source[3], dummyPluginInfo, dummyProject, {android_studio: true}); expect(removeFileSpy).toHaveBeenCalledWith(temp, path.join('app/libs/TestAar.aar')); }); + + it('Test#019d : should remove stuff by calling common.removeFile for Android Studio projects, of xml with old target-dir scheme', function () { + android['source-file'].install(valid_source[4], dummyPluginInfo, dummyProject, {android_studio: true}); + android['source-file'].uninstall(valid_source[4], dummyPluginInfo, dummyProject, {android_studio: true}); + expect(removeFileSpy).toHaveBeenCalledWith(temp, path.join('app/src/main/res/xml/mysettings.xml')); + }); }); describe('of elements', function () { From dea6846918976450b409bd2d8b2754f25d89213d Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Mon, 12 Nov 2018 22:01:13 -0500 Subject: [PATCH 12/18] Check old compat of other extension (CB-14125) (PR #550) of plugin source file installed into app/src/main with old target-dir scheme NOTE: These tests do *not* check compatibility of plugins with old lib target-dir scheme. --- .../org.test.plugins.dummyplugin/plugin.xml | 1 + .../src/android/other.extension | 1 + spec/unit/pluginHandlers/handlers.spec.js | 13 +++++++++++++ 3 files changed, 15 insertions(+) create mode 100644 spec/fixtures/org.test.plugins.dummyplugin/src/android/other.extension diff --git a/spec/fixtures/org.test.plugins.dummyplugin/plugin.xml b/spec/fixtures/org.test.plugins.dummyplugin/plugin.xml index 5cd28720..f4ae82be 100644 --- a/spec/fixtures/org.test.plugins.dummyplugin/plugin.xml +++ b/spec/fixtures/org.test.plugins.dummyplugin/plugin.xml @@ -77,6 +77,7 @@ + diff --git a/spec/fixtures/org.test.plugins.dummyplugin/src/android/other.extension b/spec/fixtures/org.test.plugins.dummyplugin/src/android/other.extension new file mode 100644 index 00000000..421376db --- /dev/null +++ b/spec/fixtures/org.test.plugins.dummyplugin/src/android/other.extension @@ -0,0 +1 @@ +dummy diff --git a/spec/unit/pluginHandlers/handlers.spec.js b/spec/unit/pluginHandlers/handlers.spec.js index 6d90bd02..5a55cb8e 100644 --- a/spec/unit/pluginHandlers/handlers.spec.js +++ b/spec/unit/pluginHandlers/handlers.spec.js @@ -134,6 +134,13 @@ describe('android project handler', function () { 'src/android/mysettings.xml', temp, path.join('app/src/main/res/xml/mysettings.xml'), false); }); + + it('Test#006e : should allow installing file with other extension from sources with old target-dir scheme', function () { + android['source-file'].install(valid_source[5], dummyPluginInfo, dummyProject, {android_studio: true}); + expect(copyFileSpy).toHaveBeenCalledWith(dummyplugin, + 'src/android/other.extension', temp, + path.join('app/src/main/res/values/other.extension'), false); + }); }); describe('of elements', function () { @@ -313,6 +320,12 @@ describe('android project handler', function () { android['source-file'].uninstall(valid_source[4], dummyPluginInfo, dummyProject, {android_studio: true}); expect(removeFileSpy).toHaveBeenCalledWith(temp, path.join('app/src/main/res/xml/mysettings.xml')); }); + + it('Test#019e : should remove stuff by calling common.removeFile for Android Studio projects, of file with other extension with old target-dir scheme', function () { + android['source-file'].install(valid_source[5], dummyPluginInfo, dummyProject, {android_studio: true}); + android['source-file'].uninstall(valid_source[5], dummyPluginInfo, dummyProject, {android_studio: true}); + expect(removeFileSpy).toHaveBeenCalledWith(temp, path.join('app/src/main/res/values/other.extension')); + }); }); describe('of elements', function () { From 9537e3468bc82141d9dd5815518aa8969c3e1799 Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Tue, 13 Nov 2018 13:06:48 -0500 Subject: [PATCH 13/18] Test old plugin aidl & lib mapping - repros GH-547 (PR #550) (reproduces GH-547) --- .../org.test.plugins.dummyplugin/plugin.xml | 4 ++ .../src/android/jniLibs/x86/libnative.so | 1 + .../src/android/myapi.aidl | 1 + .../src/android/testaar2.aar | 1 + .../src/android/testjar2.jar | Bin 0 -> 6 bytes spec/unit/pluginHandlers/handlers.spec.js | 60 ++++++++++++++++++ 6 files changed, 67 insertions(+) create mode 100644 spec/fixtures/org.test.plugins.dummyplugin/src/android/jniLibs/x86/libnative.so create mode 100644 spec/fixtures/org.test.plugins.dummyplugin/src/android/myapi.aidl create mode 100644 spec/fixtures/org.test.plugins.dummyplugin/src/android/testaar2.aar create mode 100644 spec/fixtures/org.test.plugins.dummyplugin/src/android/testjar2.jar diff --git a/spec/fixtures/org.test.plugins.dummyplugin/plugin.xml b/spec/fixtures/org.test.plugins.dummyplugin/plugin.xml index f4ae82be..4e2ebcc6 100644 --- a/spec/fixtures/org.test.plugins.dummyplugin/plugin.xml +++ b/spec/fixtures/org.test.plugins.dummyplugin/plugin.xml @@ -78,6 +78,10 @@ target-dir="app/libs" /> + + + + diff --git a/spec/fixtures/org.test.plugins.dummyplugin/src/android/jniLibs/x86/libnative.so b/spec/fixtures/org.test.plugins.dummyplugin/src/android/jniLibs/x86/libnative.so new file mode 100644 index 00000000..421376db --- /dev/null +++ b/spec/fixtures/org.test.plugins.dummyplugin/src/android/jniLibs/x86/libnative.so @@ -0,0 +1 @@ +dummy diff --git a/spec/fixtures/org.test.plugins.dummyplugin/src/android/myapi.aidl b/spec/fixtures/org.test.plugins.dummyplugin/src/android/myapi.aidl new file mode 100644 index 00000000..421376db --- /dev/null +++ b/spec/fixtures/org.test.plugins.dummyplugin/src/android/myapi.aidl @@ -0,0 +1 @@ +dummy diff --git a/spec/fixtures/org.test.plugins.dummyplugin/src/android/testaar2.aar b/spec/fixtures/org.test.plugins.dummyplugin/src/android/testaar2.aar new file mode 100644 index 00000000..421376db --- /dev/null +++ b/spec/fixtures/org.test.plugins.dummyplugin/src/android/testaar2.aar @@ -0,0 +1 @@ +dummy diff --git a/spec/fixtures/org.test.plugins.dummyplugin/src/android/testjar2.jar b/spec/fixtures/org.test.plugins.dummyplugin/src/android/testjar2.jar new file mode 100644 index 0000000000000000000000000000000000000000..421376db9e8aee847e9d774891e73098a7415e94 GIT binary patch literal 6 NcmYc(&CRXk0ssh}0yh8v literal 0 HcmV?d00001 diff --git a/spec/unit/pluginHandlers/handlers.spec.js b/spec/unit/pluginHandlers/handlers.spec.js index 5a55cb8e..71137fb5 100644 --- a/spec/unit/pluginHandlers/handlers.spec.js +++ b/spec/unit/pluginHandlers/handlers.spec.js @@ -141,6 +141,38 @@ describe('android project handler', function () { 'src/android/other.extension', temp, path.join('app/src/main/res/values/other.extension'), false); }); + + it('Test#006f : should allow installing aidl file from sources with old target-dir scheme - reproduces GH-547', function () { + // reproduces GH-547 + android['source-file'].install(valid_source[6], dummyPluginInfo, dummyProject, {android_studio: true}); + expect(copyFileSpy).toHaveBeenCalledWith(dummyplugin, + 'src/android/myapi.aidl', temp, + path.join('app/src/main/src/com/mytest/myapi.aidl'), false); + }); + + it('Test#006g : should allow installing aar lib file from sources with old target-dir scheme - reproduces GH-547', function () { + // reproduces GH-547 + android['source-file'].install(valid_source[7], dummyPluginInfo, dummyProject, {android_studio: true}); + expect(copyFileSpy).toHaveBeenCalledWith(dummyplugin, + 'src/android/testaar2.aar', temp, + path.join('app/src/main/libs/testaar2.aar'), false); + }); + + it('Test#006h : should allow installing jar lib file from sources with old target-dir scheme - reproduces GH-547', function () { + // reproduces GH-547 + android['source-file'].install(valid_source[8], dummyPluginInfo, dummyProject, {android_studio: true}); + expect(copyFileSpy).toHaveBeenCalledWith(dummyplugin, + 'src/android/testjar2.jar', temp, + path.join('app/src/main/libs/testjar2.jar'), false); + }); + + it('Test#006i : should allow installing .so lib file from sources with old target-dir scheme - reproduces GH-547', function () { + // reproduces GH-547 + android['source-file'].install(valid_source[9], dummyPluginInfo, dummyProject, {android_studio: true}); + expect(copyFileSpy).toHaveBeenCalledWith(dummyplugin, + 'src/android/jniLibs/x86/libnative.so', temp, + path.join('app/src/main/libs/x86/libnative.so'), false); + }); }); describe('of elements', function () { @@ -326,6 +358,34 @@ describe('android project handler', function () { android['source-file'].uninstall(valid_source[5], dummyPluginInfo, dummyProject, {android_studio: true}); expect(removeFileSpy).toHaveBeenCalledWith(temp, path.join('app/src/main/res/values/other.extension')); }); + + it('Test#019f : should remove stuff by calling common.removeFile for Android Studio projects, of aidl with old target-dir scheme - reproduces GH-547', function () { + // reproduces GH-547 + android['source-file'].install(valid_source[6], dummyPluginInfo, dummyProject, {android_studio: true}); + android['source-file'].uninstall(valid_source[6], dummyPluginInfo, dummyProject, {android_studio: true}); + expect(removeFileSpy).toHaveBeenCalledWith(temp, path.join('app/src/main/src/com/mytest/myapi.aidl')); + }); + + it('Test#019g : should remove stuff by calling common.removeFile for Android Studio projects, of aar with old target-dir scheme - reproduces GH-547', function () { + // reproduces GH-547 + android['source-file'].install(valid_source[7], dummyPluginInfo, dummyProject, {android_studio: true}); + android['source-file'].uninstall(valid_source[7], dummyPluginInfo, dummyProject, {android_studio: true}); + expect(removeFileSpy).toHaveBeenCalledWith(temp, path.join('app/src/main/libs/testaar2.aar')); + }); + + it('Test#019h : should remove stuff by calling common.removeFile for Android Studio projects, of jar with old target-dir scheme - reproduces GH-547', function () { + // reproduces GH-547 + android['source-file'].install(valid_source[8], dummyPluginInfo, dummyProject, {android_studio: true}); + android['source-file'].uninstall(valid_source[8], dummyPluginInfo, dummyProject, {android_studio: true}); + expect(removeFileSpy).toHaveBeenCalledWith(temp, path.join('app/src/main/libs/testjar2.jar')); + }); + + it('Test#019i : should remove stuff by calling common.removeFile for Android Studio projects, of .so lib file with old target-dir scheme - reproduces GH-547', function () { + // reproduces GH-547 + android['source-file'].install(valid_source[9], dummyPluginInfo, dummyProject, {android_studio: true}); + android['source-file'].uninstall(valid_source[9], dummyPluginInfo, dummyProject, {android_studio: true}); + expect(removeFileSpy).toHaveBeenCalledWith(temp, path.join('app/src/main/libs/x86/libnative.so')); + }); }); describe('of elements', function () { From 07e1fe18ff10212df49bb8dc25a5e6eb269d4d26 Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Wed, 14 Nov 2018 11:38:39 -0500 Subject: [PATCH 14/18] Cleanup getInstallDestination in pluginHandlers.js (PR #550) --- bin/templates/cordova/lib/pluginHandlers.js | 23 +++++++++------------ 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/bin/templates/cordova/lib/pluginHandlers.js b/bin/templates/cordova/lib/pluginHandlers.js index 18f7996a..cfdb5004 100644 --- a/bin/templates/cordova/lib/pluginHandlers.js +++ b/bin/templates/cordova/lib/pluginHandlers.js @@ -318,20 +318,17 @@ function generateAttributeError (attribute, element, id) { } function getInstallDestination (obj) { - return studioPathRemap(obj) || - path.join(obj.targetDir, path.basename(obj.src)); -} + var APP_MAIN_PREFIX = 'app/src/main'; -function studioPathRemap (obj) { - // If any source file is using the app new directory structure, - // don't penalize it - if (!obj.targetDir.includes('app')) { - if (obj.src.endsWith('.java')) { - return path.join('app/src/main/java', obj.targetDir.substring(4), path.basename(obj.src)); - } else { - // For all other files, add 'app/src/main' to the targetDir if it didn't have it already - return path.join('app/src/main', obj.targetDir, path.basename(obj.src)); - } + if (obj.targetDir.includes('app')) { + // If any source file is using the app new directory structure, + // don't penalize it + return path.join(obj.targetDir, path.basename(obj.src)); + } else if (obj.src.endsWith('.java')) { + return path.join(APP_MAIN_PREFIX, 'java', obj.targetDir.substring(4), path.basename(obj.src)); + } else { + // For all other files, add 'app/src/main' to the targetDir if it didn't have it already + return path.join(APP_MAIN_PREFIX, obj.targetDir, path.basename(obj.src)); } } From 298f1e3cc89b676ed32e089c28b343dc130c2cab Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Wed, 14 Nov 2018 11:40:33 -0500 Subject: [PATCH 15/18] Fix comments in getInstallDestination (PR #550) (in pluginHandlers.js) --- bin/templates/cordova/lib/pluginHandlers.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/templates/cordova/lib/pluginHandlers.js b/bin/templates/cordova/lib/pluginHandlers.js index cfdb5004..5b37bcaf 100644 --- a/bin/templates/cordova/lib/pluginHandlers.js +++ b/bin/templates/cordova/lib/pluginHandlers.js @@ -321,13 +321,14 @@ function getInstallDestination (obj) { var APP_MAIN_PREFIX = 'app/src/main'; if (obj.targetDir.includes('app')) { - // If any source file is using the app new directory structure, + // If any source file is using the new app directory structure, // don't penalize it return path.join(obj.targetDir, path.basename(obj.src)); } else if (obj.src.endsWith('.java')) { return path.join(APP_MAIN_PREFIX, 'java', obj.targetDir.substring(4), path.basename(obj.src)); } else { - // For all other files, add 'app/src/main' to the targetDir if it didn't have it already + // For all other source files not using the new app directory structure, + // add 'app/src/main' to the targetDir return path.join(APP_MAIN_PREFIX, obj.targetDir, path.basename(obj.src)); } From 9848aa885f66a1a5d79a0c3f08a54414703d907a Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Wed, 14 Nov 2018 13:19:58 -0500 Subject: [PATCH 16/18] GH-547 Fix for old plugins with non-Java sources (PR #550) (source-file entries) including aidl, aar, jar, and so files --- bin/templates/cordova/lib/pluginHandlers.js | 10 ++++++ spec/unit/pluginHandlers/handlers.spec.js | 40 +++++++++------------ 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/bin/templates/cordova/lib/pluginHandlers.js b/bin/templates/cordova/lib/pluginHandlers.js index 5b37bcaf..aaee3b3e 100644 --- a/bin/templates/cordova/lib/pluginHandlers.js +++ b/bin/templates/cordova/lib/pluginHandlers.js @@ -326,6 +326,16 @@ function getInstallDestination (obj) { return path.join(obj.targetDir, path.basename(obj.src)); } else if (obj.src.endsWith('.java')) { return path.join(APP_MAIN_PREFIX, 'java', obj.targetDir.substring(4), path.basename(obj.src)); + } else if (obj.src.endsWith('.aidl')) { + return path.join(APP_MAIN_PREFIX, 'aidl', obj.targetDir.substring(4), path.basename(obj.src)); + } else if (obj.targetDir.includes('libs')) { + if (obj.src.endsWith('.so')) { + return path.join(APP_MAIN_PREFIX, 'jniLibs', obj.targetDir.substring(5), path.basename(obj.src)); + } else { + return path.join('app', obj.targetDir, path.basename(obj.src)); + } + } else if (obj.targetDir.includes('src/main')) { + return path.join('app', obj.targetDir, path.basename(obj.src)); } else { // For all other source files not using the new app directory structure, // add 'app/src/main' to the targetDir diff --git a/spec/unit/pluginHandlers/handlers.spec.js b/spec/unit/pluginHandlers/handlers.spec.js index 71137fb5..97e77dce 100644 --- a/spec/unit/pluginHandlers/handlers.spec.js +++ b/spec/unit/pluginHandlers/handlers.spec.js @@ -142,36 +142,32 @@ describe('android project handler', function () { path.join('app/src/main/res/values/other.extension'), false); }); - it('Test#006f : should allow installing aidl file from sources with old target-dir scheme - reproduces GH-547', function () { - // reproduces GH-547 + it('Test#006f : should allow installing aidl file from sources with old target-dir scheme (GH-547)', function () { android['source-file'].install(valid_source[6], dummyPluginInfo, dummyProject, {android_studio: true}); expect(copyFileSpy).toHaveBeenCalledWith(dummyplugin, 'src/android/myapi.aidl', temp, - path.join('app/src/main/src/com/mytest/myapi.aidl'), false); + path.join('app/src/main/aidl/com/mytest/myapi.aidl'), false); }); - it('Test#006g : should allow installing aar lib file from sources with old target-dir scheme - reproduces GH-547', function () { - // reproduces GH-547 + it('Test#006g : should allow installing aar lib file from sources with old target-dir scheme (GH-547)', function () { android['source-file'].install(valid_source[7], dummyPluginInfo, dummyProject, {android_studio: true}); expect(copyFileSpy).toHaveBeenCalledWith(dummyplugin, 'src/android/testaar2.aar', temp, - path.join('app/src/main/libs/testaar2.aar'), false); + path.join('app/libs/testaar2.aar'), false); }); - it('Test#006h : should allow installing jar lib file from sources with old target-dir scheme - reproduces GH-547', function () { - // reproduces GH-547 + it('Test#006h : should allow installing jar lib file from sources with old target-dir scheme (GH-547)', function () { android['source-file'].install(valid_source[8], dummyPluginInfo, dummyProject, {android_studio: true}); expect(copyFileSpy).toHaveBeenCalledWith(dummyplugin, 'src/android/testjar2.jar', temp, - path.join('app/src/main/libs/testjar2.jar'), false); + path.join('app/libs/testjar2.jar'), false); }); - it('Test#006i : should allow installing .so lib file from sources with old target-dir scheme - reproduces GH-547', function () { - // reproduces GH-547 + it('Test#006i : should allow installing .so lib file from sources with old target-dir scheme (GH-547)', function () { android['source-file'].install(valid_source[9], dummyPluginInfo, dummyProject, {android_studio: true}); expect(copyFileSpy).toHaveBeenCalledWith(dummyplugin, 'src/android/jniLibs/x86/libnative.so', temp, - path.join('app/src/main/libs/x86/libnative.so'), false); + path.join('app/src/main/jniLibs/x86/libnative.so'), false); }); }); @@ -359,32 +355,28 @@ describe('android project handler', function () { expect(removeFileSpy).toHaveBeenCalledWith(temp, path.join('app/src/main/res/values/other.extension')); }); - it('Test#019f : should remove stuff by calling common.removeFile for Android Studio projects, of aidl with old target-dir scheme - reproduces GH-547', function () { - // reproduces GH-547 + it('Test#019f : should remove stuff by calling common.removeFile for Android Studio projects, of aidl with old target-dir scheme (GH-547)', function () { android['source-file'].install(valid_source[6], dummyPluginInfo, dummyProject, {android_studio: true}); android['source-file'].uninstall(valid_source[6], dummyPluginInfo, dummyProject, {android_studio: true}); - expect(removeFileSpy).toHaveBeenCalledWith(temp, path.join('app/src/main/src/com/mytest/myapi.aidl')); + expect(removeFileSpy).toHaveBeenCalledWith(temp, path.join('app/src/main/aidl/com/mytest/myapi.aidl')); }); - it('Test#019g : should remove stuff by calling common.removeFile for Android Studio projects, of aar with old target-dir scheme - reproduces GH-547', function () { - // reproduces GH-547 + it('Test#019g : should remove stuff by calling common.removeFile for Android Studio projects, of aar with old target-dir scheme (GH-547)', function () { android['source-file'].install(valid_source[7], dummyPluginInfo, dummyProject, {android_studio: true}); android['source-file'].uninstall(valid_source[7], dummyPluginInfo, dummyProject, {android_studio: true}); - expect(removeFileSpy).toHaveBeenCalledWith(temp, path.join('app/src/main/libs/testaar2.aar')); + expect(removeFileSpy).toHaveBeenCalledWith(temp, path.join('app/libs/testaar2.aar')); }); - it('Test#019h : should remove stuff by calling common.removeFile for Android Studio projects, of jar with old target-dir scheme - reproduces GH-547', function () { - // reproduces GH-547 + it('Test#019h : should remove stuff by calling common.removeFile for Android Studio projects, of jar with old target-dir scheme (GH-547)', function () { android['source-file'].install(valid_source[8], dummyPluginInfo, dummyProject, {android_studio: true}); android['source-file'].uninstall(valid_source[8], dummyPluginInfo, dummyProject, {android_studio: true}); - expect(removeFileSpy).toHaveBeenCalledWith(temp, path.join('app/src/main/libs/testjar2.jar')); + expect(removeFileSpy).toHaveBeenCalledWith(temp, path.join('app/libs/testjar2.jar')); }); - it('Test#019i : should remove stuff by calling common.removeFile for Android Studio projects, of .so lib file with old target-dir scheme - reproduces GH-547', function () { - // reproduces GH-547 + it('Test#019i : should remove stuff by calling common.removeFile for Android Studio projects, of .so lib file with old target-dir scheme (GH-547)', function () { android['source-file'].install(valid_source[9], dummyPluginInfo, dummyProject, {android_studio: true}); android['source-file'].uninstall(valid_source[9], dummyPluginInfo, dummyProject, {android_studio: true}); - expect(removeFileSpy).toHaveBeenCalledWith(temp, path.join('app/src/main/libs/x86/libnative.so')); + expect(removeFileSpy).toHaveBeenCalledWith(temp, path.join('app/src/main/jniLibs/x86/libnative.so')); }); }); From 0ebc9a6f8d80976693c1ebd796054ee7583e5282 Mon Sep 17 00:00:00 2001 From: David Boho Date: Wed, 14 Nov 2018 06:18:53 +0100 Subject: [PATCH 17/18] add missing cast for cdvMinSdkVersion (GH-551) --- bin/templates/project/app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/templates/project/app/build.gradle b/bin/templates/project/app/build.gradle index e82c6264..27a2b83f 100644 --- a/bin/templates/project/app/build.gradle +++ b/bin/templates/project/app/build.gradle @@ -117,7 +117,7 @@ if (ext.cdvReleaseSigningPropertiesFile == null && file('../release-signing.prop // Cast to appropriate types. ext.cdvBuildMultipleApks = cdvBuildMultipleApks == null ? false : cdvBuildMultipleApks.toBoolean(); ext.cdvVersionCodeForceAbiDigit = cdvVersionCodeForceAbiDigit == null ? false : cdvVersionCodeForceAbiDigit.toBoolean(); -ext.cdvMinSdkVersion = cdvMinSdkVersion == null ? defaultMinSdkVersion : cdvMinSdkVersion +ext.cdvMinSdkVersion = cdvMinSdkVersion == null ? defaultMinSdkVersion : Integer.parseInt('' + cdvMinSdkVersion) ext.cdvVersionCode = cdvVersionCode == null ? null : Integer.parseInt('' + cdvVersionCode) def computeBuildTargetName(debugBuild) { From 32e3eae83ef3c7513f0455f8c81b30843250ab91 Mon Sep 17 00:00:00 2001 From: David Boho Date: Wed, 14 Nov 2018 14:00:36 +0100 Subject: [PATCH 18/18] GH-552 (android) check for build-extras.gradle in the app-parent directory (#553) as documented in https://cordova.apache.org/docs/en/latest/guide/platforms/android/?#extending-buildgradle and deal with multiple build-extras.gradle locations Co-authored-by: David Boho Co-authored-by: Christopher J. Brody --- bin/templates/project/app/build.gradle | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bin/templates/project/app/build.gradle b/bin/templates/project/app/build.gradle index 27a2b83f..4830dd93 100644 --- a/bin/templates/project/app/build.gradle +++ b/bin/templates/project/app/build.gradle @@ -93,11 +93,16 @@ ext { // PLUGIN GRADLE EXTENSIONS START // PLUGIN GRADLE EXTENSIONS END -def hasBuildExtras = file('build-extras.gradle').exists() -if (hasBuildExtras) { +def hasBuildExtras1 = file('build-extras.gradle').exists() +if (hasBuildExtras1) { apply from: 'build-extras.gradle' } +def hasBuildExtras2 = file('../build-extras.gradle').exists() +if (hasBuildExtras2) { + apply from: '../build-extras.gradle' +} + // Set property defaults after extension .gradle files. if (ext.cdvCompileSdkVersion == null) { ext.cdvCompileSdkVersion = privateHelpers.getProjectTarget()