cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject [1/5] cordova-lib git commit: CB-8390 android: Make `<framework custom=false>` work with Gradle
Date Fri, 06 Feb 2015 20:32:39 GMT
Repository: cordova-lib
Updated Branches:
  refs/heads/CB-8416 adab8c9ac -> 0d0279c84


CB-8390 android: Make `<framework custom=false>` work with Gradle


Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/60f19284
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/60f19284
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/60f19284

Branch: refs/heads/CB-8416
Commit: 60f19284ce5b8e265e2348ba88907fc47af42007
Parents: 5f957e5
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Mon Feb 2 21:06:30 2015 -0500
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Mon Feb 2 22:28:42 2015 -0500

----------------------------------------------------------------------
 .../spec-plugman/install-browserify.spec.js     |   2 +-
 cordova-lib/spec-plugman/install.spec.js        |   2 +-
 .../spec-plugman/platforms/android.spec.js      | 227 +++++++++----------
 .../org.test.plugins.dummyplugin/extra.gradle   |   1 +
 .../plugin-lib/AndroidManifest.xml              |   5 +
 .../plugin-lib/libFile                          |   1 +
 .../plugin-lib/project.properties               |   1 +
 .../org.test.plugins.dummyplugin/plugin.xml     |   3 +
 .../projects/android_install/local.properties   |   1 +
 .../projects/android_one/project.properties     |   4 +
 .../projects/android_uninstall/local.properties |   1 +
 .../spec-plugman/uninstall-browserify.spec.js   |   2 +-
 cordova-lib/spec-plugman/uninstall.spec.js      |  30 +--
 cordova-lib/src/plugman/install.js              |  16 +-
 cordova-lib/src/plugman/platforms/android.js    |  70 +++---
 cordova-lib/src/plugman/util/action-stack.js    |  14 +-
 cordova-lib/src/plugman/util/android-project.js |  47 +++-
 17 files changed, 238 insertions(+), 189 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/60f19284/cordova-lib/spec-plugman/install-browserify.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/install-browserify.spec.js b/cordova-lib/spec-plugman/install-browserify.spec.js
index 963a8b2..c6f6869 100644
--- a/cordova-lib/spec-plugman/install-browserify.spec.js
+++ b/cordova-lib/spec-plugman/install-browserify.spec.js
@@ -211,7 +211,7 @@ describe('install', function() {
         });
         it('should queue up actions as appropriate for that plugin and call process on the
action stack',
            function() {
-                expect(results['actions_callCount']).toEqual(3);
+                expect(results['actions_callCount']).toEqual(6);
                 expect(results['actions_create']).toEqual([jasmine.any(Function), [jasmine.any(Object),
path.join(plugins_install_dir, dummy_id), project, dummy_id, jasmine.any(Object)], jasmine.any(Function),
[jasmine.any(Object), project, dummy_id, jasmine.any(Object)]]);
         });
 

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/60f19284/cordova-lib/spec-plugman/install.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/install.spec.js b/cordova-lib/spec-plugman/install.spec.js
index 69c2aba..1a7cfa0 100644
--- a/cordova-lib/spec-plugman/install.spec.js
+++ b/cordova-lib/spec-plugman/install.spec.js
@@ -209,7 +209,7 @@ describe('install', function() {
         });
         it('should queue up actions as appropriate for that plugin and call process on the
action stack',
            function() {
-                expect(results['actions_callCount']).toEqual(3);
+                expect(results['actions_callCount']).toEqual(6);
                 expect(results['actions_create']).toEqual([jasmine.any(Function), [jasmine.any(Object),
path.join(plugins_install_dir, dummy_id), project, dummy_id, jasmine.any(Object)], jasmine.any(Function),
[jasmine.any(Object), project, dummy_id, jasmine.any(Object)]]);
         });
 

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/60f19284/cordova-lib/spec-plugman/platforms/android.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/platforms/android.spec.js b/cordova-lib/spec-plugman/platforms/android.spec.js
index c6bbd7d..4fabc80 100644
--- a/cordova-lib/spec-plugman/platforms/android.spec.js
+++ b/cordova-lib/spec-plugman/platforms/android.spec.js
@@ -20,14 +20,11 @@
 /* jshint sub:true */
 
 var android = require('../../src/plugman/platforms/android'),
-    android_project = require('../../src/plugman/util/android-project'),
     common  = require('../../src/plugman/platforms/common'),
-    install = require('../../src/plugman/install'),
     path    = require('path'),
     fs      = require('fs'),
     shell   = require('shelljs'),
     os      = require('osenv'),
-    _       = require('underscore'),
     temp    = path.join(os.tmpdir(), 'plugman'),
     plugins_dir = path.join(temp, 'cordova', 'plugins'),
     dummyplugin = path.join(__dirname, '..', 'plugins', 'org.test.plugins.dummyplugin'),
@@ -115,85 +112,108 @@ describe('android project handler', function() {
                 }).toThrow('"' + target + '" already exists!');
             });
         });
-        describe('of <framework> elements', function() {
-            afterEach(function() {
-                android.purgeProjectFileCache(temp);
-            });
-            it('with custom=true should update the main and library projects', function()
{
-                var packageIdSuffix = 'PlugmanTest';
-                var packageId = 'io.cordova.' + packageIdSuffix;
-                var frameworkElement = { src: 'LibraryPath', custom: true };
-                var subDir = path.resolve(temp, dummy_id, packageIdSuffix + '-' + frameworkElement.src);
-                var mainProjectPropsFile = path.resolve(temp, 'project.properties');
-                var mainProjectManifestFile = path.resolve(temp, 'AndroidManifest.xml');
-                var subProjectPropsFile = path.resolve(subDir, 'project.properties');
-
-                spyOn( fs, 'existsSync').andReturn(true);
-                var writeFileSync = spyOn(fs, 'writeFileSync');
-                spyOn(common, 'copyNewFile');
-                spyOn(fs, 'readFileSync').andCallFake(function (file) {
-                    file = path.normalize(file);
-                    if (file === mainProjectPropsFile) {
-                        return '#Some comment\ntarget=android-19\nandroid.library.reference.1=ExistingLibRef1\nandroid.library.reference.2=ExistingLibRef2';
-                    } else if (file === subProjectPropsFile) {
-                        return '#Some comment\ntarget=android-17\nandroid.library=true';
-                    } else if (file === mainProjectManifestFile) {
-                        return '<manifest package="' + packageId + '">';
-                    } else {
-                        throw new Error('Trying to read from an unexpected file ' + file
+ '\n expected: ' + mainProjectPropsFile + '\n' + subProjectPropsFile);
-                    }
-                });
-                spyOn(shell, 'exec');
-
-                android['framework'].install(frameworkElement, dummyplugin, temp, dummy_id);
-                android.parseProjectFile(temp).write();
-
-                expect(_.any(writeFileSync.argsForCall, function (callArgs) {
-                    return callArgs[0] === mainProjectPropsFile && callArgs[1].indexOf('\nandroid.library.reference.3='+dummy_id+'/'+packageIdSuffix+'-LibraryPath')
> -1;
-                })).toBe(true, 'Reference to library not added');
-                expect(_.any(writeFileSync.argsForCall, function (callArgs) {
-                    return callArgs[0] === subProjectPropsFile && callArgs[1].indexOf('\ntarget=android-19')
> -1;
-                })).toBe(true, 'target SDK version not copied to library');
-                expect(shell.exec).toHaveBeenCalledWith('android update lib-project --path
"' + subDir + '"');
-            });
-            it('with custom=false should update the main and library projects', function()
{
-                var frameworkElement = { src: 'extras/android/support/v7/appcompat' };
-                var subDir = path.resolve('~/android-sdk', frameworkElement.src);
-                var localPropsFile = path.resolve(temp, 'local.properties');
-                var mainProjectPropsFile = path.resolve(temp, 'project.properties');
-                var subProjectPropsFile = path.resolve(subDir, 'project.properties');
-
-                spyOn( fs, 'existsSync').andReturn(true);
-                var writeFileSync = spyOn(fs, 'writeFileSync');
-                spyOn(common, 'copyNewFile');
-                spyOn(fs, 'readFileSync').andCallFake(function (file) {
-                    if (path.normalize(file) === mainProjectPropsFile) {
-                        return '#Some comment\ntarget=android-19\nandroid.library.reference.1=ExistingLibRef1\nandroid.library.reference.2=ExistingLibRef2';
-                    } else if (path.normalize(file) === subProjectPropsFile) {
-                        return '#Some comment\ntarget=android-17\nandroid.library=true';
-                    } else if (path.normalize(file) === localPropsFile) {
-                        return 'sdk.dir=~/android-sdk';
-                    } else {
-                        throw new Error('Trying to read from an unexpected file ' + file);
-                    }
-                });
-                spyOn(shell, 'exec');
-
-                android['framework'].install(frameworkElement, dummyplugin, temp, dummy_id);
-                android.parseProjectFile(temp).write();
-
-                var relativePath = android_project.getRelativeLibraryPath(temp, subDir);
-                expect(_.any(writeFileSync.argsForCall, function (callArgs) {
-                    return callArgs[0] === mainProjectPropsFile && callArgs[1].indexOf('\nandroid.library.reference.3='
+ relativePath) > -1;
-                })).toBe(true, 'Reference to library not added');
-                expect(_.any(writeFileSync.argsForCall, function (callArgs) {
-                    return callArgs[0] === subProjectPropsFile && callArgs[1].indexOf('\ntarget=android-19')
> -1;
-                })).toBe(true, 'target SDK version not copied to library');
-                expect(shell.exec).toHaveBeenCalledWith('android update lib-project --path
"' + subDir + '"');
-            });
-        });
     });
 
+    describe('<framework> elements', function() {
+        beforeEach(function() {
+            shell.cp('-rf', android_one_project, temp);
+        });
+        afterEach(function() {
+            shell.rm('-rf', temp);
+            android.purgeProjectFileCache(temp);
+        });
+        it('with custom=true', function() {
+            var packageIdSuffix = 'childapp';
+            var frameworkElement = { src: 'plugin-lib', custom: true };
+            var mainProjectPropsFile = path.resolve(temp, 'project.properties');
+            var subDir = path.resolve(temp, dummy_id, packageIdSuffix + '-' + frameworkElement.src);
+            var subProjectPropsFile = path.resolve(subDir, 'project.properties');
+
+            var exec = spyOn(shell, 'exec');
+
+            android['framework'].install(frameworkElement, dummyplugin, temp, dummy_id, {
platformVersion: '3.0.0' });
+            android.parseProjectFile(temp).write();
+
+            var finalProjectProperties = fs.readFileSync(mainProjectPropsFile, 'utf8');
+            expect(finalProjectProperties).toMatch('\nandroid.library.reference.3='+dummy_id+'/'+packageIdSuffix+'-plugin-lib',
'Reference to library not added');
+            var subProjectProperties = fs.readFileSync(subProjectPropsFile, 'utf8');
+            expect(subProjectProperties).toMatch(/\btarget=android-19\n/, 'target SDK version
not copied to library');
+            expect(exec).toHaveBeenCalledWith('android update lib-project --path "' + subDir
+ '"');
+
+            // Now test uninstall
+            android.purgeProjectFileCache(temp);
+            android['framework'].uninstall(frameworkElement, temp, dummy_id, {platformVersion:
'3.0.0'});
+            android.parseProjectFile(temp).write();
+
+            finalProjectProperties = fs.readFileSync(mainProjectPropsFile, 'utf8');
+            expect(finalProjectProperties).not.toMatch('\nandroid.library.reference.3='+dummy_id+'/'+packageIdSuffix+'-plugin-lib',
'Reference to library not added');
+            expect(fs.existsSync(subDir)).toBe(false, 'Should delete subdir');
+        });
+        it('with custom=true type=gradleReference', function() {
+            var packageIdSuffix = 'childapp';
+            var frameworkElement = { src: 'extra.gradle', custom: true, type: 'gradleReference'};
+            var mainProjectPropsFile = path.resolve(temp, 'project.properties');
+            var subDir = path.resolve(temp, dummy_id, packageIdSuffix + '-' + frameworkElement.src);
+
+            android['framework'].install(frameworkElement, dummyplugin, temp, dummy_id, {platformVersion:
'3.0.0'});
+            android.parseProjectFile(temp).write();
+
+            var finalProjectProperties = fs.readFileSync(mainProjectPropsFile, 'utf8');
+            expect(finalProjectProperties).toMatch('\ncordova.gradle.include.1='+dummy_id+'/'+packageIdSuffix+'-extra.gradle',
'Reference to gradle not added');
+
+            // Now test uninstall
+            android.purgeProjectFileCache(temp);
+            android['framework'].uninstall(frameworkElement, temp, dummy_id, {platformVersion:
'3.0.0'});
+            android.parseProjectFile(temp).write();
+
+            finalProjectProperties = fs.readFileSync(mainProjectPropsFile, 'utf8');
+            expect(finalProjectProperties).not.toMatch('\ncordova.gradle.include.1='+dummy_id+'/'+packageIdSuffix+'-extra.gradle',
'Reference to gradle not added');
+            expect(fs.existsSync(subDir)).toBe(false, 'Should delete subdir');
+        });
+        it('with custom=false pre 4.0', function() {
+            var packageIdSuffix = 'childapp';
+            var frameworkElement = { src: 'extras/android/support/v4', custom: false};
+            var mainProjectPropsFile = path.resolve(temp, 'project.properties');
+            fs.writeFileSync(path.join(temp, 'local.properties'), 'sdk.dir=' + path.join(path.dirname(temp),
'SDK').replace(/\\/g, '/'));
+
+            var exec = spyOn(shell, 'exec');
+            android['framework'].install(frameworkElement, dummyplugin, temp, dummy_id, {
platformVersion: '3.0.0'});
+            android.parseProjectFile(temp).write();
+
+            // exec doesn't get called since plugin dir doesn't actually exist.
+            expect(exec).not.toHaveBeenCalled();
+            var finalProjectProperties = fs.readFileSync(mainProjectPropsFile, 'utf8');
+            expect(finalProjectProperties).toMatch('\nandroid.library.reference.3=' + '../SDK/extras/android/support/v4',
'Sublibrary not added');
+
+            // Now test uninstall
+            android.purgeProjectFileCache(temp);
+            android['framework'].uninstall(frameworkElement, temp, dummy_id, { platformVersion:
'3.0.0'});
+            android.parseProjectFile(temp).write();
+
+            finalProjectProperties = fs.readFileSync(mainProjectPropsFile, 'utf8');
+            expect(finalProjectProperties).not.toMatch('\ncordova.gradle.include.1='+dummy_id+'/'+packageIdSuffix+'-extra.gradle',
'Reference to gradle not added');
+        });
+        it('with custom=false post 4.0', function() {
+            var frameworkElement = { src: 'extras/android/support/v4', custom: false};
+            var mainProjectPropsFile = path.resolve(temp, 'project.properties');
+            fs.writeFileSync(path.join(temp, 'local.properties'), 'sdk.dir=' + path.join(temp,
'..', 'SDK'));
+
+            android['framework'].install(frameworkElement, dummyplugin, temp, dummy_id, {
platformVersion: '4.0.0-dev'});
+            android.parseProjectFile(temp).write();
+
+            var finalProjectProperties = fs.readFileSync(mainProjectPropsFile, 'utf8');
+            expect(finalProjectProperties).toMatch('\ncordova.system.library.1=' + 'extras/android/support/v4',
'Sublibrary not added');
+            expect(finalProjectProperties).not.toMatch('\nandroid.library.reference.3=' +
path.join('..', 'SDK', 'extras', 'android', 'support', 'v4'), 'Sublibrary not added');
+
+            // Now test uninstall
+            android.purgeProjectFileCache(temp);
+            android['framework'].uninstall(frameworkElement, temp, dummy_id, { platformVersion:
'4.0.0-dev'});
+            android.parseProjectFile(temp).write();
+
+            finalProjectProperties = fs.readFileSync(mainProjectPropsFile, 'utf8');
+            expect(finalProjectProperties).not.toMatch('\ncordova.system.library.1=' + 'extras/android/support/v4',
'Sublibrary not added');
+        });
+    });
     describe('uninstallation', function() {
         beforeEach(function() {
             shell.mkdir('-p', temp);
@@ -220,49 +240,12 @@ describe('android project handler', function() {
             });
         });
         describe('of <source-file> elements', function() {
-            it('should remove stuff by calling common.deleteJava', function(done) {
+            it('should remove stuff by calling common.deleteJava', function() {
                 var s = spyOn(common, 'deleteJava');
-                install('android', temp, dummyplugin, plugins_dir, {})
-                .then(function() {
-                    var source = copyArray(valid_source);
-                    android['source-file'].uninstall(source[0], temp);
-                    expect(s).toHaveBeenCalledWith(temp, path.join('src', 'com', 'phonegap',
'plugins', 'dummyplugin', 'DummyPlugin.java'));
-                    done();
-                });
-            });
-        });
-        describe('of <framework> elements', function() {
-            afterEach(function () {
-                android.purgeProjectFileCache(temp);
-            });
-            it('should remove library reference from the main project', function () {
-                var packageIdSuffix = 'PlugmanTest';
-                var packageId = 'io.cordova.' + packageIdSuffix;
-                var frameworkElement = { src: 'LibraryPath', custom: true };
-                path.resolve(temp, dummy_id, packageIdSuffix + '-' + frameworkElement.src);
-                var mainProjectProps = path.resolve(temp, 'project.properties');
-                var mainProjectManifest = path.resolve(temp, 'AndroidManifest.xml');
-                spyOn(fs, 'existsSync').andReturn(true);
-                var writeFileSync = spyOn(fs, 'writeFileSync');
-                spyOn(fs, 'readdirSync').andReturn([]);
-                var rmdirSync = spyOn(fs, 'rmdirSync');
-                spyOn(common, 'removeFile');
-                spyOn(fs, 'readFileSync').andCallFake(function (file) {
-                    if (path.normalize(file) === mainProjectProps) {
-                        return '#Some comment\ntarget=android-19\nandroid.library.reference.1=ExistingLibRef1\nandroid.library.reference.2='+dummy_id+'/'+packageIdSuffix+'-LibraryPath\nandroid.library.reference.3=ExistingLibRef2\n';
-                    } else if (path.normalize(file) === mainProjectManifest) {
-                        return '<manifest package="' + packageId + '">';
-                    }
-                });
-                spyOn(shell, 'exec');
-
-                android['framework'].uninstall(frameworkElement, temp, dummy_id);
-                android.parseProjectFile(temp).write();
-
-                expect(_.any(writeFileSync.argsForCall, function (callArgs) {
-                    return callArgs[0] === mainProjectProps && callArgs[1].indexOf('\nandroid.library.reference.2=ExistingLibRef2')
> -1;
-                })).toBe(true, 'Reference to library not removed');
-                expect(rmdirSync).toHaveBeenCalledWith(path.join(temp, dummy_id));
+                android['source-file'].install(valid_source[0], dummyplugin, temp, dummy_id);
+                var source = copyArray(valid_source);
+                android['source-file'].uninstall(source[0], temp, dummy_id);
+                expect(s).toHaveBeenCalledWith(temp, path.join('src', 'com', 'phonegap',
'plugins', 'dummyplugin', 'DummyPlugin.java'));
             });
         });
     });

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/60f19284/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/extra.gradle
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/extra.gradle b/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/extra.gradle
new file mode 100644
index 0000000..5b828a9
--- /dev/null
+++ b/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/extra.gradle
@@ -0,0 +1 @@
+extra.gradle

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/60f19284/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/plugin-lib/AndroidManifest.xml
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/plugin-lib/AndroidManifest.xml
b/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/plugin-lib/AndroidManifest.xml
new file mode 100644
index 0000000..3c9499c
--- /dev/null
+++ b/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/plugin-lib/AndroidManifest.xml
@@ -0,0 +1,5 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+  android:versionCode="1" package="com.test.somelib">
+    <uses-sdk android:minSdkVersion="9"/>
+    <application/>
+</manifest>

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/60f19284/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/plugin-lib/libFile
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/plugin-lib/libFile
b/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/plugin-lib/libFile
new file mode 100644
index 0000000..c79df8e
--- /dev/null
+++ b/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/plugin-lib/libFile
@@ -0,0 +1 @@
+libFile contents

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/60f19284/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/plugin-lib/project.properties
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/plugin-lib/project.properties
b/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/plugin-lib/project.properties
new file mode 100644
index 0000000..c4a5b63
--- /dev/null
+++ b/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/plugin-lib/project.properties
@@ -0,0 +1 @@
+target=android-11

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/60f19284/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/plugin.xml
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/plugin.xml b/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/plugin.xml
index 0d7d94b..f61ec7c 100644
--- a/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/plugin.xml
+++ b/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/plugin.xml
@@ -50,6 +50,9 @@
             </activity>
         </config-file>
 
+        <framework src="plugin-lib" custom="true" />
+        <framework src="extras/android/support/v7/appcompat" />
+        <framework src="extra.gradle" type="gradleReference" />
         <resource-file src="android-resource.xml" target="res/xml/dummy.xml" />
 
         <!-- CDV < 2.0 -->

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/60f19284/cordova-lib/spec-plugman/projects/android_install/local.properties
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/projects/android_install/local.properties b/cordova-lib/spec-plugman/projects/android_install/local.properties
new file mode 100644
index 0000000..cdf2deb
--- /dev/null
+++ b/cordova-lib/spec-plugman/projects/android_install/local.properties
@@ -0,0 +1 @@
+sdk.dir=foo

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/60f19284/cordova-lib/spec-plugman/projects/android_one/project.properties
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/projects/android_one/project.properties b/cordova-lib/spec-plugman/projects/android_one/project.properties
new file mode 100644
index 0000000..3e95c96
--- /dev/null
+++ b/cordova-lib/spec-plugman/projects/android_one/project.properties
@@ -0,0 +1,4 @@
+#Some comment
+target=android-19
+android.library.reference.1=ExistingLibRef1
+android.library.reference.2=ExistingLibRef2

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/60f19284/cordova-lib/spec-plugman/projects/android_uninstall/local.properties
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/projects/android_uninstall/local.properties b/cordova-lib/spec-plugman/projects/android_uninstall/local.properties
new file mode 100644
index 0000000..cdf2deb
--- /dev/null
+++ b/cordova-lib/spec-plugman/projects/android_uninstall/local.properties
@@ -0,0 +1 @@
+sdk.dir=foo

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/60f19284/cordova-lib/spec-plugman/uninstall-browserify.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/uninstall-browserify.spec.js b/cordova-lib/spec-plugman/uninstall-browserify.spec.js
index d8db429..d68b0a6 100644
--- a/cordova-lib/spec-plugman/uninstall-browserify.spec.js
+++ b/cordova-lib/spec-plugman/uninstall-browserify.spec.js
@@ -123,7 +123,7 @@ describe('uninstallPlatform', function() {
             });
             waitsFor(function() { return done; }, 'promise never resolved', 200);
             runs(function() {
-                expect(actions_push.calls.length).toEqual(5);
+                expect(actions_push.calls.length).toEqual(6);
                 expect(proc).toHaveBeenCalled();
             });
         });

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/60f19284/cordova-lib/spec-plugman/uninstall.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/uninstall.spec.js b/cordova-lib/spec-plugman/uninstall.spec.js
index 89df356..6cff6b0 100644
--- a/cordova-lib/spec-plugman/uninstall.spec.js
+++ b/cordova-lib/spec-plugman/uninstall.spec.js
@@ -62,18 +62,20 @@ describe('start', function() {
 
         done = false;
         promise = Q()
-        .then(
-            function(){ return install('android', project, plugins['org.test.plugins.dummyplugin']);
}
-        ).then(
-            function(){ return install('android', project, plugins['A']); }
-        ).then(
-            function(){ return install('android', project2, plugins['C']); }
-        ).then(
-            function(){ return install('android', project2, plugins['A']); }
-        ).then(
-            function(){ done = true; }
-        );
-        waitsFor(function() { return done; }, 'promise never resolved', 1000);
+        .then(function(){
+            return install('android', project, plugins['org.test.plugins.dummyplugin']);
+        }).then(function(){
+            return install('android', project, plugins['A']);
+        }).then( function(){
+            return install('android', project2, plugins['C']);
+        }).then(function(){
+            return install('android', project2, plugins['A']);
+        }).then(function(){
+            done = true;
+        }, function(err) {
+            done = err.stack;
+        });
+        waitsFor(function() { return done; }, 'promise never resolved', 500);
         runs(function() {
             expect(done).toBe(true);
         });
@@ -120,7 +122,7 @@ describe('uninstallPlatform', function() {
             });
             waitsFor(function() { return done; }, 'promise never resolved', 200);
             runs(function() {
-                expect(actions_push.calls.length).toEqual(5);
+                expect(actions_push.calls.length).toEqual(6);
                 expect(proc).toHaveBeenCalled();
             });
         });
@@ -290,7 +292,7 @@ describe('end', function() {
             }
         ).fail(
             function(err) {
-                expect(err.message).toBe('The plugin \'C\' is required by (A), skipping uninstallation.');
+                expect(err.stack).toMatch(/The plugin 'C' is required by \(A\), skipping
uninstallation./);
             }
         ).then(
             function(){

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/60f19284/cordova-lib/src/plugman/install.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/install.js b/cordova-lib/src/plugman/install.js
index c9f16f9..0c95ad5 100644
--- a/cordova-lib/src/plugman/install.js
+++ b/cordova-lib/src/plugman/install.js
@@ -38,6 +38,7 @@ var path = require('path'),
     isWindows = (os.platform().substr(0,3) === 'win'),
     cordovaUtil = require('../cordova/util');
 
+var superspawn = require('../cordova/superspawn');
 var PluginInfo = require('../PluginInfo');
 var PluginInfoProvider = require('../PluginInfoProvider');
 
@@ -276,10 +277,17 @@ function runInstall(actions, platform, project_dir, plugin_dir, plugins_dir,
opt
         top_plugin_dir: plugin_dir
     };
 
-    return callEngineScripts(theEngines)
-    .then(checkEngines)
-    .then(
-        function() {
+    return Q().then(function() {
+        if (options.platformVersion) {
+            return Q(options.platformVersion);
+        }
+        return Q(superspawn.maybeSpawn(path.join(project_dir, 'cordova', 'version')));
+    }).then(function(platformVersion) {
+        options.platformVersion = platformVersion;
+        return callEngineScripts(theEngines);
+    }).then(function(engines) {
+        return checkEngines(engines);
+    }).then(function() {
             // checking preferences, if certain variables are not provided, we should throw.
             var prefs = pluginInfo.getPreferences(platform);
             options.cli_variables = options.cli_variables || {};

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/60f19284/cordova-lib/src/plugman/platforms/android.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/platforms/android.js b/cordova-lib/src/plugman/platforms/android.js
index d819d16..40fe6ce 100644
--- a/cordova-lib/src/plugman/platforms/android.js
+++ b/cordova-lib/src/plugman/platforms/android.js
@@ -28,9 +28,29 @@ var path = require('path')
    , android_project = require('../util/android-project')
    , CordovaError = require('../../CordovaError')
    ;
+var semver = require('semver');
 
 var projectFileCache = {};
 
+function getProjectSdkDir(project_dir) {
+    var localProperties = properties_parser.createEditor(path.resolve(project_dir, 'local.properties'));
+    return localProperties.get('sdk.dir');
+}
+
+function getCustomSubprojectRelativeDir(plugin_id, project_dir, src) {
+    // All custom subprojects are prefixed with the last portion of the package id.
+    // This is to avoid collisions when opening multiple projects in Eclipse that have subprojects
with the same name.
+    var prefix = package_suffix(project_dir);
+    var subRelativeDir = path.join(plugin_id, prefix + '-' + path.basename(src));
+    return subRelativeDir;
+}
+
+function package_suffix(project_dir) {
+    var packageName = module.exports.package_name(project_dir);
+    var lastDotIndex = packageName.lastIndexOf('.');
+    return packageName.substring(lastDotIndex + 1);
+}
+
 module.exports = {
     www_dir:function(project_dir) {
         return path.join(project_dir, 'assets', 'www');
@@ -43,11 +63,6 @@ module.exports = {
 
         return mDoc._root.attrib['package'];
     },
-    package_suffix:function(project_dir) {
-        var packageName = module.exports.package_name(project_dir);
-        var lastDotIndex = packageName.lastIndexOf('.');
-        return packageName.substring(lastDotIndex + 1);
-    },
     'source-file':{
         install:function(obj, plugin_dir, project_dir, plugin_id, options) {
             var src = obj.src;
@@ -109,23 +124,30 @@ module.exports = {
             var parent = obj.parent;
             var parentDir = parent ? path.resolve(project_dir, parent) : project_dir;
             var subDir;
+            var type = obj.type;
 
             if (custom) {
-                var subRelativeDir = module.exports.getCustomSubprojectRelativeDir(plugin_id,
project_dir, src);
+                var subRelativeDir = getCustomSubprojectRelativeDir(plugin_id, project_dir,
src);
                 common.copyNewFile(plugin_dir, src, project_dir, subRelativeDir, options
&& options.link);
                 subDir = path.resolve(project_dir, subRelativeDir);
             } else {
-                var sdk_dir = module.exports.getProjectSdkDir(project_dir);
-                subDir = path.resolve(sdk_dir, src);
+                if (semver.gte(options.platformVersion, '4.0.0-dev')) {
+                    type = 'sys';
+                    subDir = src;
+                } else {
+                    var sdk_dir = getProjectSdkDir(project_dir);
+                    subDir = path.resolve(sdk_dir, src);
+                }
             }
 
             var projectConfig = module.exports.parseProjectFile(project_dir);
-            var type = obj.type;
             if (type == 'gradleReference') {
-                //add reference to build.gradle
                 projectConfig.addGradleReference(parentDir, subDir);
+            } else if (type == 'sys') {
+                projectConfig.addSystemLibrary(parentDir, subDir);
             } else {
                 projectConfig.addSubProject(parentDir, subDir);
+                projectConfig.needsSubLibraryUpdate = semver.lt(options.platformVersion,
'3.6.0');
             }
         },
         uninstall:function(obj, project_dir, plugin_id, options) {
@@ -137,9 +159,10 @@ module.exports = {
             var parent = obj.parent;
             var parentDir = parent ? path.resolve(project_dir, parent) : project_dir;
             var subDir;
+            var type = obj.type;
 
             if (custom) {
-                var subRelativeDir = module.exports.getCustomSubprojectRelativeDir(plugin_id,
project_dir, src);
+                var subRelativeDir = getCustomSubprojectRelativeDir(plugin_id, project_dir,
src);
                 common.removeFile(project_dir, subRelativeDir);
                 subDir = path.resolve(project_dir, subRelativeDir);
                 // If it's the last framework in the plugin, remove the parent directory.
@@ -148,14 +171,20 @@ module.exports = {
                     fs.rmdirSync(parDir);
                 }
             } else {
-                var sdk_dir = module.exports.getProjectSdkDir(project_dir);
-                subDir = path.resolve(sdk_dir, src);
+                if (semver.gte(options.platformVersion, '4.0.0-dev')) {
+                    type = 'sys';
+                    subDir = src;
+                } else {
+                    var sdk_dir = getProjectSdkDir(project_dir);
+                    subDir = path.resolve(sdk_dir, src);
+                }
             }
 
             var projectConfig = module.exports.parseProjectFile(project_dir);
-            var type = obj.type;
             if (type == 'gradleReference') {
                 projectConfig.removeGradleReference(parentDir, subDir);
+            } else if (type == 'sys') {
+                projectConfig.removeSystemLibrary(parentDir, subDir);
             } else {
                 projectConfig.removeSubProject(parentDir, subDir);
             }
@@ -163,24 +192,13 @@ module.exports = {
     },
     parseProjectFile: function(project_dir){
         if (!projectFileCache[project_dir]) {
-            projectFileCache[project_dir] = new android_project.AndroidProject();
+            projectFileCache[project_dir] = new android_project.AndroidProject(project_dir);
         }
 
         return projectFileCache[project_dir];
     },
     purgeProjectFileCache:function(project_dir) {
         delete projectFileCache[project_dir];
-    },
-    getProjectSdkDir: function (project_dir) {
-        var localProperties = properties_parser.createEditor(path.resolve(project_dir, 'local.properties'));
-        return localProperties.get('sdk.dir');
-    },
-    getCustomSubprojectRelativeDir: function (plugin_id, project_dir, src) {
-        // All custom subprojects are prefixed with the last portion of the package id.
-        // This is to avoid collisions when opening multiple projects in Eclipse that have
subprojects with the same name.
-        var prefix = module.exports.package_suffix(project_dir);
-        var subRelativeDir = path.join(plugin_id, prefix + '-' + path.basename(src));
-        return subRelativeDir;
     }
 };
 

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/60f19284/cordova-lib/src/plugman/util/action-stack.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/util/action-stack.js b/cordova-lib/src/plugman/util/action-stack.js
index 89387cd..a62883d 100644
--- a/cordova-lib/src/plugman/util/action-stack.js
+++ b/cordova-lib/src/plugman/util/action-stack.js
@@ -22,8 +22,6 @@
 var platforms = require("../platforms"),
     events = require('../../events'),
     Q = require('q');
-var superspawn = require('../../cordova/superspawn');
-var path = require('path');
 
 function ActionStack() {
     this.stack = [];
@@ -95,13 +93,11 @@ ActionStack.prototype = {
         }
         events.emit('verbose', 'Action stack processing complete.');
 
-        return superspawn.maybeSpawn(path.join(project_dir, 'cordova', 'version'))
-        .then(function(platformVersion) {
-            if (project_files) {
-                events.emit('verbose', 'Writing out ' + platform + ' project files...');
-                project_files.write(platformVersion);
-            }
-        });
+        if (project_files) {
+            events.emit('verbose', 'Writing out ' + platform + ' project files...');
+            project_files.write();
+        }
+        return Q();
     }
 };
 

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/60f19284/cordova-lib/src/plugman/util/android-project.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/util/android-project.js b/cordova-lib/src/plugman/util/android-project.js
index a8c056a..77908fb 100644
--- a/cordova-lib/src/plugman/util/android-project.js
+++ b/cordova-lib/src/plugman/util/android-project.js
@@ -26,7 +26,6 @@ var fs = require('fs'),
     path = require('path'),
     properties_parser = require('properties-parser'),
     shell = require('shelljs');
-var semver = require('semver');
 
 
 function addToPropertyList(projectProperties, key, value) {
@@ -35,6 +34,7 @@ function addToPropertyList(projectProperties, key, value) {
         i++;
 
     projectProperties.set(key + '.' + i, value);
+    projectProperties.dirty = true;
 }
 
 function removeFromPropertyList(projectProperties, key, value) {
@@ -51,14 +51,15 @@ function removeFromPropertyList(projectProperties, key, value) {
         }
         i++;
     }
+    projectProperties.dirty = true;
 }
 
-function AndroidProject() {
+function AndroidProject(projectDir) {
     this._propertiesEditors = {};
     this._subProjectDirs = {};
     this._dirty = false;
-
-    return this;
+    this.projectDir = projectDir;
+    this.needsSubLibraryUpdate = false;
 }
 
 AndroidProject.prototype = {
@@ -70,6 +71,7 @@ AndroidProject.prototype = {
         if (fs.existsSync(subProjectFile)) {
             var subProperties = this._getPropertiesFile(subProjectFile);
             subProperties.set('target', parentProperties.get('target'));
+            subProperties.dirty = true;
             this._subProjectDirs[subDir] = true;
         }
         addToPropertyList(parentProperties, 'android.library.reference', module.exports.getRelativeLibraryPath(parentDir,
subDir));
@@ -95,18 +97,36 @@ AndroidProject.prototype = {
         removeFromPropertyList(parentProperties, 'cordova.gradle.include', module.exports.getRelativeLibraryPath(parentDir,
subDir));
         this._dirty = true;
     },
-    write: function(platformVersion) {
-        if (!this._dirty) return;
+    addSystemLibrary: function(parentDir, value) {
+        var parentProjectFile = path.resolve(parentDir, 'project.properties');
+        var parentProperties = this._getPropertiesFile(parentProjectFile);
+        addToPropertyList(parentProperties, 'cordova.system.library', value);
+        this._dirty = true;
+    },
+    removeSystemLibrary: function(parentDir, value) {
+        var parentProjectFile = path.resolve(parentDir, 'project.properties');
+        var parentProperties = this._getPropertiesFile(parentProjectFile);
+        removeFromPropertyList(parentProperties, 'cordova.system.library', value);
+        this._dirty = true;
+    },
+    write: function() {
+        if (!this._dirty) {
+            return;
+        }
+        this._dirty = false;
 
         for (var filename in this._propertiesEditors) {
-            fs.writeFileSync(filename, this._propertiesEditors[filename].toString());
+            var editor = this._propertiesEditors[filename];
+            if (editor.dirty) {
+                fs.writeFileSync(filename, editor.toString());
+                editor.dirty = false;
+            }
         }
 
         // Starting with 3.6.0, the build scripts set ANDROID_HOME, so there is
         // no reason to keep run this command. Plus - we really want to avoid
         // relying on the presense of native SDKs within plugman.
-        var needsUpdateProject = !platformVersion || semver.lt(platformVersion, '3.6.0');
-        if (needsUpdateProject) {
+        if (this.needsSubLibraryUpdate) {
             for (var sub_dir in this._subProjectDirs)
             {
                 shell.exec('android update lib-project --path "' + sub_dir + '"');
@@ -115,8 +135,13 @@ AndroidProject.prototype = {
         this._dirty = false;
     },
     _getPropertiesFile: function (filename) {
-        if (!this._propertiesEditors[filename])
-            this._propertiesEditors[filename] = properties_parser.createEditor(filename);
+        if (!this._propertiesEditors[filename]) {
+            if (fs.existsSync(filename)) {
+                this._propertiesEditors[filename] = properties_parser.createEditor(filename);
+            } else {
+                this._propertiesEditors[filename] = properties_parser.createEditor();
+            }
+        }
 
         return this._propertiesEditors[filename];
     }


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


Mime
View raw message