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/12 17:21:50 UTC
[GitHub] brodybits closed pull request #539: Fix dest overwrite
brodybits closed pull request #539: Fix dest overwrite
URL: https://github.com/apache/cordova-android/pull/539
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 a3ebed0eb..e78e3ee4e 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')) {
diff --git a/spec/fixtures/org.test.plugins.dummyplugin/plugin.xml b/spec/fixtures/org.test.plugins.dummyplugin/plugin.xml
index a40df2b28..5451ef8da 100644
--- a/spec/fixtures/org.test.plugins.dummyplugin/plugin.xml
+++ b/spec/fixtures/org.test.plugins.dummyplugin/plugin.xml
@@ -70,6 +70,8 @@
<source-file src="src/android/DummyPlugin.java"
target-dir="src/com/phonegap/plugins/dummyplugin" />
+ <source-file src="src/android/DummyPlugin2.java"
+ target-dir="app/src/main/src/com/phonegap/plugins/dummyplugin" />
<lib-file src="src/android/TestLib.jar" />
</platform>
</plugin>
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 000000000..c2dd0f731
--- /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 edc8f43bc..206de56e2 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 <framework> elements', function () {
@@ -257,6 +263,10 @@ describe('android project handler', function () {
});
});
+ // TODO:
+ // - merge tests of <source-file> elements into single describe block
+ // (with proper beforeEach/afterEach)
+ // - renumber the tests after Test#019
describe('of <source-file> 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});
@@ -265,6 +275,14 @@ describe('android project handler', function () {
});
});
+ describe('of <source-file> 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 <framework> elements', function () {
var someString = jasmine.any(String);
----------------------------------------------------------------
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