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/22 13:59:36 UTC

[GitHub] brodybits closed pull request #572: Resolve issue with plugin target-dir="app*" subdirs

brodybits closed pull request #572: Resolve issue with plugin target-dir="app*" subdirs
URL: https://github.com/apache/cordova-android/pull/572
 
 
   

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 794154b54..25890ba23 100644
--- a/bin/templates/cordova/lib/pluginHandlers.js
+++ b/bin/templates/cordova/lib/pluginHandlers.js
@@ -295,7 +295,7 @@ function generateAttributeError (attribute, element, id) {
 function getInstallDestination (obj) {
     var APP_MAIN_PREFIX = 'app/src/main';
 
-    if (obj.targetDir.includes('app')) {
+    if (obj.targetDir.startsWith('app')) {
         // If any source file is using the new app directory structure,
         // don't penalize it
         return path.join(obj.targetDir, path.basename(obj.src));
diff --git a/spec/fixtures/org.test.plugins.dummyplugin/plugin.xml b/spec/fixtures/org.test.plugins.dummyplugin/plugin.xml
index 4e2ebcc6c..9bc99d21d 100644
--- a/spec/fixtures/org.test.plugins.dummyplugin/plugin.xml
+++ b/spec/fixtures/org.test.plugins.dummyplugin/plugin.xml
@@ -82,6 +82,8 @@
 	<source-file src="src/android/testaar2.aar" target-dir="libs" />
 	<source-file src="src/android/testjar2.jar" target-dir="libs" />
 	<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" />
         <lib-file src="src/android/TestLib.jar" />
     </platform>
 </plugin>
diff --git a/spec/unit/pluginHandlers/handlers.spec.js b/spec/unit/pluginHandlers/handlers.spec.js
index 20f5e6e93..31e7b453b 100644
--- a/spec/unit/pluginHandlers/handlers.spec.js
+++ b/spec/unit/pluginHandlers/handlers.spec.js
@@ -163,6 +163,12 @@ describe('android project handler', function () {
                     'src/android/jniLibs/x86/libnative.so', temp,
                     path.join('app/src/main/jniLibs/x86/libnative.so'), false);
             });
+
+            it('Test#006j : should allow installing sources with target-dir that includes "app"', function () {
+                android['source-file'].install(valid_source[10], dummyPluginInfo, dummyProject, {android_studio: true});
+                expect(copyFileSpy)
+                    .toHaveBeenCalledWith(dummyplugin, 'src/android/DummyPlugin2.java', temp, path.join('app/src/main/java/com/appco/DummyPlugin2.java'), false);
+            });
         });
 
         describe('of <framework> elements', function () {
@@ -372,6 +378,12 @@ describe('android project handler', function () {
                 android['source-file'].uninstall(valid_source[9], dummyPluginInfo, dummyProject, {android_studio: true});
                 expect(removeFileSpy).toHaveBeenCalledWith(temp, path.join('app/src/main/jniLibs/x86/libnative.so'));
             });
+
+            it('Test#019j : should remove stuff by calling common.deleteJava for Android Studio projects, with target-dir that includes "app"', function () {
+                android['source-file'].install(valid_source[10], dummyPluginInfo, dummyProject, {android_studio: true});
+                android['source-file'].uninstall(valid_source[10], dummyPluginInfo, dummyProject, {android_studio: true});
+                expect(deleteJavaSpy).toHaveBeenCalledWith(temp, path.join('app/src/main/java/com/appco/DummyPlugin2.java'));
+            });
         });
 
         describe('of <framework> elements', 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