You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2018/11/26 20:08:33 UTC

[GitHub] brodybits closed pull request #577: Other target-dir remapping fixes

brodybits closed pull request #577: Other target-dir remapping fixes
URL: https://github.com/apache/cordova-android/pull/577
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/bin/templates/cordova/lib/pluginHandlers.js b/bin/templates/cordova/lib/pluginHandlers.js
index 25890ba23..74316b346 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,
diff --git a/spec/fixtures/org.test.plugins.dummyplugin/plugin.xml b/spec/fixtures/org.test.plugins.dummyplugin/plugin.xml
index 9bc99d21d..b8b14590c 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" />
         <source-file src="src/android/DummyPlugin2.java"
                 target-dir="app/src/main/src/com/phonegap/plugins/dummyplugin" />
-        <source-file src="src/android/TestLib.jar"
+        <source-file src="src/android/test1.jar"
                 target-dir="app/libs" />
         <source-file src="src/android/TestAar.aar"
                 target-dir="app/libs" />
@@ -84,6 +84,10 @@
 	<source-file src="src/android/jniLibs/x86/libnative.so" target-dir="libs/x86" />
         <source-file src="src/android/DummyPlugin2.java"
                 target-dir="src/com/appco" />
+        <source-file src="src/android/mysettings.xml"
+		target-dir="res/xml/appsrc/mainstreet" />
+        <source-file src="src/android/mysettings.xml"
+		target-dir="res/xml/glibsoft" />
         <lib-file src="src/android/TestLib.jar" />
     </platform>
 </plugin>
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 000000000..9daeafb98
--- /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 31e7b453b..fa81c5fe5 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 () {
@@ -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 <framework> elements', function () {
@@ -334,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 () {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org