From 9bd952f8aa0df431d039d84881b8c4948520a0e8 Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Fri, 23 Nov 2018 10:34:45 -0500 Subject: [PATCH 1/3] Other target-dir remapping fixes Use `startsWith` instead of `includes` to check for remapping of `target-dir` that starts with `libs` or `src/main` (Followup to PR #572) --- bin/templates/cordova/lib/pluginHandlers.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/templates/cordova/lib/pluginHandlers.js b/bin/templates/cordova/lib/pluginHandlers.js index 25890ba235..74316b3464 100644 --- a/bin/templates/cordova/lib/pluginHandlers.js +++ b/bin/templates/cordova/lib/pluginHandlers.js @@ -303,13 +303,13 @@ function getInstallDestination (obj) { 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')) { + } else if (obj.targetDir.startsWith('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')) { + } else if (obj.targetDir.startsWith('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, From f79eda477bc5b68c758f78309312dec52ee957da Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Sun, 25 Nov 2018 18:07:04 -0500 Subject: [PATCH 2/3] Tests for other target-dir remapping fixes --- .../fixtures/org.test.plugins.dummyplugin/plugin.xml | 4 ++++ spec/unit/pluginHandlers/handlers.spec.js | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/spec/fixtures/org.test.plugins.dummyplugin/plugin.xml b/spec/fixtures/org.test.plugins.dummyplugin/plugin.xml index 9bc99d21dd..2d60c45c74 100644 --- a/spec/fixtures/org.test.plugins.dummyplugin/plugin.xml +++ b/spec/fixtures/org.test.plugins.dummyplugin/plugin.xml @@ -84,6 +84,10 @@ + + diff --git a/spec/unit/pluginHandlers/handlers.spec.js b/spec/unit/pluginHandlers/handlers.spec.js index 31e7b453b9..025e1cfa17 100644 --- a/spec/unit/pluginHandlers/handlers.spec.js +++ b/spec/unit/pluginHandlers/handlers.spec.js @@ -169,6 +169,18 @@ describe('android project handler', function () { expect(copyFileSpy) .toHaveBeenCalledWith(dummyplugin, 'src/android/DummyPlugin2.java', temp, path.join('app/src/main/java/com/appco/DummyPlugin2.java'), false); }); + + it('Test#006k : should properly install non-Java sources with target-dir="src/mainstreetapps" (includes "src/main")', function () { + android['source-file'].install(valid_source[11], dummyPluginInfo, dummyProject, {android_studio: true}); + expect(copyFileSpy) + .toHaveBeenCalledWith(dummyplugin, 'src/android/mysettings.xml', temp, path.join('app/src/main/res/xml/appsrc/mainstreet/mysettings.xml'), false); + }); + + it('Test#006l : should properly install non-Java sources with target-dir="src/com/glibsoft" (includes "libs")', function () { + android['source-file'].install(valid_source[12], dummyPluginInfo, dummyProject, {android_studio: true}); + expect(copyFileSpy) + .toHaveBeenCalledWith(dummyplugin, 'src/android/mysettings.xml', temp, path.join('app/src/main/res/xml/glibsoft/mysettings.xml'), false); + }); }); describe('of elements', function () { From 8f4df1afe9da1c09ff5ec71f4ab34dcb89f97b86 Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Mon, 26 Nov 2018 11:56:55 -0500 Subject: [PATCH 3/3] test1.jar in plugin handlers Test#006b & Test#019b --- spec/fixtures/org.test.plugins.dummyplugin/plugin.xml | 2 +- .../org.test.plugins.dummyplugin/src/android/test1.jar | 1 + spec/unit/pluginHandlers/handlers.spec.js | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 spec/fixtures/org.test.plugins.dummyplugin/src/android/test1.jar diff --git a/spec/fixtures/org.test.plugins.dummyplugin/plugin.xml b/spec/fixtures/org.test.plugins.dummyplugin/plugin.xml index 2d60c45c74..b8b14590c8 100644 --- a/spec/fixtures/org.test.plugins.dummyplugin/plugin.xml +++ b/spec/fixtures/org.test.plugins.dummyplugin/plugin.xml @@ -72,7 +72,7 @@ target-dir="src/com/phonegap/plugins/dummyplugin" /> - diff --git a/spec/fixtures/org.test.plugins.dummyplugin/src/android/test1.jar b/spec/fixtures/org.test.plugins.dummyplugin/src/android/test1.jar new file mode 100644 index 0000000000..9daeafb986 --- /dev/null +++ b/spec/fixtures/org.test.plugins.dummyplugin/src/android/test1.jar @@ -0,0 +1 @@ +test diff --git a/spec/unit/pluginHandlers/handlers.spec.js b/spec/unit/pluginHandlers/handlers.spec.js index 025e1cfa17..fa81c5fe53 100644 --- a/spec/unit/pluginHandlers/handlers.spec.js +++ b/spec/unit/pluginHandlers/handlers.spec.js @@ -113,7 +113,7 @@ describe('android project handler', 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); + .toHaveBeenCalledWith(dummyplugin, 'src/android/test1.jar', temp, path.join('app/libs/test1.jar'), false); }); it('Test#006c : should allow installing aar lib file from sources with new app target-dir scheme', function () { @@ -346,7 +346,7 @@ describe('android project handler', 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')); + expect(removeFileSpy).toHaveBeenCalledWith(temp, path.join('app/libs/test1.jar')); }); it('Test#019c : should remove stuff by calling common.removeFile for Android Studio projects, of aar with new app target-dir scheme', function () {