You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2013/09/04 19:59:16 UTC
[1/3] git commit: [CB-4430] Add tests for lib-file support on Android.
Updated Branches:
refs/heads/master d9ee339d3 -> db43ef252
[CB-4430] Add tests for lib-file support on Android.
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/db43ef25
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/db43ef25
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/db43ef25
Branch: refs/heads/master
Commit: db43ef2522d3330b25927c7e482c3e663547f783
Parents: c5bdcf0
Author: Andrew Grieve <ag...@chromium.org>
Authored: Wed Sep 4 13:58:04 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Wed Sep 4 13:58:51 2013 -0400
----------------------------------------------------------------------
spec/install.spec.js | 2 +-
spec/platforms/android.spec.js | 17 +++++++++++++++++
spec/plugins/DummyPlugin/plugin.xml | 1 +
spec/plugins/DummyPlugin/src/android/TestLib.jar | 0
spec/uninstall.spec.js | 4 ++--
5 files changed, 21 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/db43ef25/spec/install.spec.js
----------------------------------------------------------------------
diff --git a/spec/install.spec.js b/spec/install.spec.js
index 04fd7c2..1639fce 100644
--- a/spec/install.spec.js
+++ b/spec/install.spec.js
@@ -108,7 +108,7 @@ describe('install', function() {
});
it('should queue up actions as appropriate for that plugin and call process on the action stack', function() {
install('android', temp, dummyplugin, plugins_dir, {});
- expect(actions_push.calls.length).toEqual(3);
+ expect(actions_push.calls.length).toEqual(4);
expect(c_a).toHaveBeenCalledWith(jasmine.any(Function), [jasmine.any(Object), path.join(plugins_dir, dummyplugin), temp, dummy_id], jasmine.any(Function), [jasmine.any(Object), temp, dummy_id]);
expect(proc).toHaveBeenCalled();
});
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/db43ef25/spec/platforms/android.spec.js
----------------------------------------------------------------------
diff --git a/spec/platforms/android.spec.js b/spec/platforms/android.spec.js
index cecb191..cafa730 100644
--- a/spec/platforms/android.spec.js
+++ b/spec/platforms/android.spec.js
@@ -23,6 +23,7 @@ var xml_path = path.join(dummyplugin, 'plugin.xml')
var platformTag = plugin_et.find('./platform[@name="android"]');
var dummy_id = plugin_et._root.attrib['id'];
var valid_source = platformTag.findall('./source-file'),
+ valid_libs = platformTag.findall('./lib-file'),
assets = plugin_et.findall('./asset'),
configChanges = platformTag.findall('./config-file');
@@ -65,6 +66,14 @@ describe('android project handler', function() {
afterEach(function() {
shell.rm('-rf', temp);
});
+ describe('of <lib-file> elements', function() {
+ it("should copy jar files to project/libs", function () {
+ var s = spyOn(common, 'copyFile');
+
+ android['lib-file'].install(valid_libs[0], dummyplugin, temp);
+ expect(s).toHaveBeenCalledWith(dummyplugin, 'src/android/TestLib.jar', temp, path.join('libs', 'TestLib.jar'));
+ });
+ });
describe('of <source-file> elements', function() {
beforeEach(function() {
shell.cp('-rf', android_one_project, temp);
@@ -106,6 +115,14 @@ describe('android project handler', function() {
afterEach(function() {
shell.rm('-rf', temp);
});
+ describe('of <lib-file> elements', function(done) {
+ it('should remove jar files', function () {
+ var s = spyOn(common, 'removeFile');
+ android['lib-file'].install(valid_libs[0], dummyplugin, temp);
+ android['lib-file'].uninstall(valid_libs[0], temp, dummy_id);
+ expect(s).toHaveBeenCalledWith(temp, path.join('libs', 'TestLib.jar'));
+ });
+ });
describe('of <source-file> elements', function() {
it('should remove stuff by calling common.deleteJava', function(done) {
var s = spyOn(common, 'deleteJava');
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/db43ef25/spec/plugins/DummyPlugin/plugin.xml
----------------------------------------------------------------------
diff --git a/spec/plugins/DummyPlugin/plugin.xml b/spec/plugins/DummyPlugin/plugin.xml
index 61e4e52..fad5072 100644
--- a/spec/plugins/DummyPlugin/plugin.xml
+++ b/spec/plugins/DummyPlugin/plugin.xml
@@ -64,6 +64,7 @@
<source-file src="src/android/DummyPlugin.java"
target-dir="src/com/phonegap/plugins/dummyplugin" />
+ <lib-file src="src/android/TestLib.jar" />
</platform>
<!-- blackberry10 -->
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/db43ef25/spec/plugins/DummyPlugin/src/android/TestLib.jar
----------------------------------------------------------------------
diff --git a/spec/plugins/DummyPlugin/src/android/TestLib.jar b/spec/plugins/DummyPlugin/src/android/TestLib.jar
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/db43ef25/spec/uninstall.spec.js
----------------------------------------------------------------------
diff --git a/spec/uninstall.spec.js b/spec/uninstall.spec.js
index 0b6dd0c..74ef25f 100644
--- a/spec/uninstall.spec.js
+++ b/spec/uninstall.spec.js
@@ -54,7 +54,7 @@ describe('uninstallPlatform', function() {
});
it('should queue up actions as appropriate for that plugin and call process on the action stack', function() {
uninstall.uninstallPlatform('android', temp, dummyplugin, plugins_dir, {});
- expect(actions_push.calls.length).toEqual(3);
+ expect(actions_push.calls.length).toEqual(4);
expect(c_a).toHaveBeenCalledWith(jasmine.any(Function), [jasmine.any(Object), temp, dummy_id], jasmine.any(Function), [jasmine.any(Object), path.join(plugins_dir, dummyplugin), temp, dummy_id]);
expect(proc).toHaveBeenCalled();
});
@@ -210,7 +210,7 @@ describe('uninstall', function() {
});
it('should queue up actions as appropriate for that plugin and call process on the action stack', function() {
uninstall('android', temp, dummyplugin, plugins_dir, {});
- expect(actions_push.calls.length).toEqual(3);
+ expect(actions_push.calls.length).toEqual(4);
expect(c_a).toHaveBeenCalledWith(jasmine.any(Function), [jasmine.any(Object), temp, dummy_id], jasmine.any(Function), [jasmine.any(Object), path.join(plugins_dir, dummyplugin), temp, dummy_id]);
expect(proc).toHaveBeenCalled();
});
[2/3] git commit: [CB-4430] Add lib-file support to Android
Posted by ag...@apache.org.
[CB-4430] Add lib-file support to Android
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/c5bdcf0e
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/c5bdcf0e
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/c5bdcf0e
Branch: refs/heads/master
Commit: c5bdcf0eb3b1484973a79fc071fecbf873ae9865
Parents: c2461bc
Author: ignisvulpis <ax...@nennker.de>
Authored: Tue Aug 20 16:09:48 2013 +0200
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Wed Sep 4 13:58:51 2013 -0400
----------------------------------------------------------------------
src/platforms/android.js | 12 ++++++++++++
1 file changed, 12 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/c5bdcf0e/src/platforms/android.js
----------------------------------------------------------------------
diff --git a/src/platforms/android.js b/src/platforms/android.js
index 7e64d9f..83b2d02 100644
--- a/src/platforms/android.js
+++ b/src/platforms/android.js
@@ -43,5 +43,17 @@ module.exports = {
var dest = path.join(source_el.attrib['target-dir'], path.basename(source_el.attrib['src']));
common.deleteJava(project_dir, dest);
}
+ },
+ "lib-file":{
+ install:function(lib_el, plugin_dir, project_dir) {
+ var src = lib_el.attrib.src;
+ var dest = path.join("libs", path.basename(src));
+ common.copyFile(plugin_dir, src, project_dir, dest);
+ },
+ uninstall:function(lib_el, project_dir) {
+ var src = lib_el.attrib.src;
+ var dest = path.join("libs", path.basename(src));
+ common.removeFile(project_dir, dest);
+ }
}
};
[3/3] git commit: [CB-4714] Add -f option to 'plugin rm' to
forcefully remove a plugin.
Posted by ag...@apache.org.
[CB-4714] Add -f option to 'plugin rm' to forcefully remove a plugin.
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/c2461bc9
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/c2461bc9
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/c2461bc9
Branch: refs/heads/master
Commit: c2461bc946555a3f43928d35ba1768c3cdcff03a
Parents: d9ee339
Author: jbondc <jb...@openmv.com>
Authored: Mon Sep 2 09:53:40 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Wed Sep 4 13:58:51 2013 -0400
----------------------------------------------------------------------
src/uninstall.js | 28 ++++++++++++++++++++--------
src/util/dependencies.js | 10 ++++++++--
2 files changed, 28 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/c2461bc9/src/uninstall.js
----------------------------------------------------------------------
diff --git a/src/uninstall.js b/src/uninstall.js
index c0cddf5..f87ec20 100644
--- a/src/uninstall.js
+++ b/src/uninstall.js
@@ -44,8 +44,10 @@ module.exports.uninstallPlatform = function(platform, project_dir, id, plugins_d
module.exports.uninstallPlugin = function(id, plugins_dir, callback) {
var plugin_dir = path.join(plugins_dir, id);
- // If already removed, skip.
+
+ // If already removed, skip.
if (!fs.existsSync(plugin_dir)) {
+ // console.log("Skipped " + plugin_dir + " (not found)");
if (callback) callback();
return;
}
@@ -75,24 +77,34 @@ module.exports.uninstallPlugin = function(id, plugins_dir, callback) {
// possible options: cli_variables, www_dir, is_top_level
function runUninstall(actions, platform, project_dir, plugin_dir, plugins_dir, options, callback) {
- var xml_path = path.join(plugin_dir, 'plugin.xml')
- , plugin_et = xml_helpers.parseElementtreeSync(xml_path);
+ var xml_path = path.join(plugin_dir, 'plugin.xml');
+ if (!fs.existsSync(xml_path)) {
+ // log warning?
+ return;
+ }
+
+ var plugin_et = xml_helpers.parseElementtreeSync(xml_path);
var plugin_id = plugin_et._root.attrib['id'];
options = options || {};
- var dependency_info = dependencies.generate_dependency_info(plugins_dir, platform);
+ var dependency_info = dependencies.generate_dependency_info(plugins_dir, platform, 'remove');
var graph = dependency_info.graph;
var dependents = graph.getChain(plugin_id);
+ var forced = options.cmd && (options.cmd.indexOf('-f') + options.cmd.indexOf('-force') > -2);
var tlps = dependency_info.top_level_plugins;
var diff_arr = [];
tlps.forEach(function(tlp) {
if (tlp != plugin_id) {
var ds = graph.getChain(tlp);
if (options.is_top_level && ds.indexOf(plugin_id) > -1) {
- var err = new Error('Another top-level plugin (' + tlp + ') relies on plugin ' + plugin_id + ', therefore aborting uninstallation.');
- if (callback) return callback(err);
- else throw err;
+ if(forced) {
+ require('../plugman').emit('log', tlp + ' depends on '+ plugin_id + ', but forcing removal...');
+ } else {
+ var err = new Error('Another top-level plugin (' + tlp + ') relies on plugin ' + plugin_id + ', therefore aborting uninstallation.');
+ if (callback) return callback(err);
+ else throw err;
+ }
}
diff_arr.push(ds);
}
@@ -171,7 +183,7 @@ function handleUninstall(actions, platform, plugin_id, plugin_et, project_dir, w
// queue up the plugin so prepare can remove the config changes
config_changes.add_uninstalled_plugin_to_prepare_queue(plugins_dir, path.basename(plugin_dir), platform, is_top_level);
// call prepare after a successful uninstall
- require('./../plugman').prepare(project_dir, platform, plugins_dir);
+ require('../plugman').prepare(project_dir, platform, plugins_dir);
if (callback) callback();
}
});
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/c2461bc9/src/util/dependencies.js
----------------------------------------------------------------------
diff --git a/src/util/dependencies.js b/src/util/dependencies.js
index 32e07eb..bf40eb1 100644
--- a/src/util/dependencies.js
+++ b/src/util/dependencies.js
@@ -1,10 +1,11 @@
var dep_graph = require('dep-graph'),
path = require('path'),
+ fs = require('fs'),
config_changes = require('./config-changes'),
xml_helpers = require('./xml-helpers');
module.exports = {
- generate_dependency_info:function(plugins_dir, platform) {
+ generate_dependency_info:function(plugins_dir, platform, context) {
var json = config_changes.get_platform_json(plugins_dir, platform);
var tlps = [];
var graph = new dep_graph();
@@ -18,7 +19,12 @@ module.exports = {
});
});
Object.keys(json.dependent_plugins).forEach(function(plug) {
- var xml = xml_helpers.parseElementtreeSync(path.join(plugins_dir, plug, 'plugin.xml'));
+ var xmlPath = path.join(plugins_dir, plug, 'plugin.xml');
+ if (context == 'remove' && !fs.existsSync(xmlPath)) {
+ return; // dependency may have been forcefully removed
+ }
+
+ var xml = xml_helpers.parseElementtreeSync(xmlPath);
var deps = xml.findall('dependency');
deps && deps.forEach(function(dep) {
var id = dep.attrib.id;