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 2014/09/11 03:57:13 UTC

git commit: CB-7518 Don't run "android update lib-project" for android 3.6.0

Repository: cordova-lib
Updated Branches:
  refs/heads/master c2f3a735c -> 1fba040ac


CB-7518 Don't run "android update lib-project" for android 3.6.0

It's no longer required.


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

Branch: refs/heads/master
Commit: 1fba040aca7dda41c3aa197bb083241034f036f8
Parents: c2f3a73
Author: Andrew Grieve <ag...@chromium.org>
Authored: Wed Sep 10 21:55:46 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Wed Sep 10 21:57:08 2014 -0400

----------------------------------------------------------------------
 cordova-lib/package.json                        |  2 +-
 .../spec-plugman/install-browserify.spec.js     |  6 +++--
 cordova-lib/spec-plugman/install.spec.js        |  5 +++-
 .../projects/android_install/cordova/version    | 24 +++++++++++++++++++-
 .../projects/android_one/cordova/version.bat    |  2 ++
 .../projects/android_uninstall/cordova/version  | 23 ++++++++++++++++++-
 cordova-lib/src/cordova/platform.js             | 17 +++-----------
 cordova-lib/src/cordova/superspawn.js           |  7 ++++++
 cordova-lib/src/plugman/util/action-stack.js    | 15 +++++++-----
 cordova-lib/src/plugman/util/android-project.js | 15 ++++++++----
 10 files changed, 86 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/1fba040a/cordova-lib/package.json
----------------------------------------------------------------------
diff --git a/cordova-lib/package.json b/cordova-lib/package.json
index d227154..0c7e380 100644
--- a/cordova-lib/package.json
+++ b/cordova-lib/package.json
@@ -31,7 +31,7 @@
     "rc": "0.3.0",
     "request": "2.22.0",
     "semver": "2.0.x",
-    "shelljs": "0.1.x",
+    "shelljs": "0.3.x",
     "tar": "0.1.x",
     "underscore": "1.4.4",
     "xcode": "0.6.7",

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/1fba040a/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 1731707..356b7a4 100644
--- a/cordova-lib/spec-plugman/install-browserify.spec.js
+++ b/cordova-lib/spec-plugman/install-browserify.spec.js
@@ -53,7 +53,8 @@ var install = require('../src/plugman/install'),
     },
     promise,
     results = {},
-    dummy_id = 'com.phonegap.plugins.dummyplugin';
+    dummy_id = 'com.phonegap.plugins.dummyplugin',
+    superspawn = require('../src/cordova/superspawn');
 
 
 // Pre-crete the temp dir, without it the test fails.
@@ -150,14 +151,15 @@ describe('start', function() {
 
 describe('install', function() {
     var chmod, exec, proc, add_to_queue, prepare, actions_push, c_a, mkdir, cp, rm, fetchSpy, emit;
+    var spawnSpy;
 
     beforeEach(function() {
         prepare = spyOn(plugman, 'prepare').andReturn( Q(true) );
         prepareBrowserify = spyOn(plugman, 'prepareBrowserify');
         exec = spyOn(child_process, 'exec').andCallFake(function(cmd, cb) {
-
             cb(false, '', '');
         });
+        spawnSpy = spyOn(superspawn, 'spawn').andReturn(Q('3.1.0'));
         spyOn(fs, 'mkdirSync').andReturn(true);
         spyOn(shell, 'mkdir').andReturn(true);
         spyOn(platforms, 'copyFile').andReturn(true);

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/1fba040a/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 3fe8428..7b83d2a 100644
--- a/cordova-lib/spec-plugman/install.spec.js
+++ b/cordova-lib/spec-plugman/install.spec.js
@@ -52,7 +52,8 @@ var install = require('../src/plugman/install'),
     },
     promise,
     results = {},
-    dummy_id = 'com.phonegap.plugins.dummyplugin';
+    dummy_id = 'com.phonegap.plugins.dummyplugin',
+    superspawn = require('../src/cordova/superspawn');
 
 
 // Pre-crete the temp dir, without it the test fails.
@@ -147,6 +148,7 @@ describe('start', function() {
 
 describe('install', function() {
     var chmod, exec, proc, add_to_queue, prepare, actions_push, c_a, mkdir, cp, rm, fetchSpy, emit;
+    var spawnSpy;
 
     beforeEach(function() {
         prepare = spyOn(plugman, 'prepare').andReturn( Q(true) );
@@ -154,6 +156,7 @@ describe('install', function() {
         exec = spyOn(child_process, 'exec').andCallFake(function(cmd, cb) {
             cb(false, '', '');
         });
+        spawnSpy = spyOn(superspawn, 'spawn').andReturn(Q('3.1.0'));
         spyOn(fs, 'mkdirSync').andReturn(true);
         spyOn(shell, 'mkdir').andReturn(true);
         spyOn(platforms, 'copyFile').andReturn(true);

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/1fba040a/cordova-lib/spec-plugman/projects/android_install/cordova/version
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/projects/android_install/cordova/version b/cordova-lib/spec-plugman/projects/android_install/cordova/version
old mode 100644
new mode 100755
index 01f68fd..3c331da
--- a/cordova-lib/spec-plugman/projects/android_install/cordova/version
+++ b/cordova-lib/spec-plugman/projects/android_install/cordova/version
@@ -1 +1,23 @@
-echo 9.0.0
\ No newline at end of file
+#!/usr/bin/env node
+
+/*
+       Licensed to the Apache Software Foundation (ASF) under one
+       or more contributor license agreements.  See the NOTICE file
+       distributed with this work for additional information
+       regarding copyright ownership.  The ASF licenses this file
+       to you under the Apache License, Version 2.0 (the
+       "License"); you may not use this file except in compliance
+       with the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+       Unless required by applicable law or agreed to in writing,
+       software distributed under the License is distributed on an
+       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+       KIND, either express or implied.  See the License for the
+       specific language governing permissions and limitations
+       under the License.
+*/
+
+console.log('9.0.0');
+

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/1fba040a/cordova-lib/spec-plugman/projects/android_one/cordova/version.bat
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/projects/android_one/cordova/version.bat b/cordova-lib/spec-plugman/projects/android_one/cordova/version.bat
new file mode 100644
index 0000000..c637d7c
--- /dev/null
+++ b/cordova-lib/spec-plugman/projects/android_one/cordova/version.bat
@@ -0,0 +1,2 @@
+@ECHO OFF
+echo 9.0.0
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/1fba040a/cordova-lib/spec-plugman/projects/android_uninstall/cordova/version
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/projects/android_uninstall/cordova/version b/cordova-lib/spec-plugman/projects/android_uninstall/cordova/version
old mode 100644
new mode 100755
index 01f68fd..3b8e2c5
--- a/cordova-lib/spec-plugman/projects/android_uninstall/cordova/version
+++ b/cordova-lib/spec-plugman/projects/android_uninstall/cordova/version
@@ -1 +1,22 @@
-echo 9.0.0
\ No newline at end of file
+#!/usr/bin/env node
+
+/*
+       Licensed to the Apache Software Foundation (ASF) under one
+       or more contributor license agreements.  See the NOTICE file
+       distributed with this work for additional information
+       regarding copyright ownership.  The ASF licenses this file
+       to you under the Apache License, Version 2.0 (the
+       "License"); you may not use this file except in compliance
+       with the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+       Unless required by applicable law or agreed to in writing,
+       software distributed under the License is distributed on an
+       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+       KIND, either express or implied.  See the License for the
+       specific language governing permissions and limitations
+       under the License.
+*/
+
+console.log('9.0.0');

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/1fba040a/cordova-lib/src/cordova/platform.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/platform.js b/cordova-lib/src/cordova/platform.js
index c206f37..487803e 100644
--- a/cordova-lib/src/cordova/platform.js
+++ b/cordova-lib/src/cordova/platform.js
@@ -46,17 +46,6 @@ for (var p in platforms) {
     module.exports[p] = platforms[p];
 }
 
-function getVersionFromScript(script, defaultValue) {
-    var versionPromise = Q(defaultValue);
-    if (fs.existsSync(script)) {
-        versionPromise = superspawn.spawn(script);
-    } else {
-        /* if you are here, it's probably because you're in Jasmine: fix your existsSync stub */
-        versionPromise = Q(defaultValue);
-    }
-    return versionPromise;
-}
-
 function add(hooks, projectRoot, targets, opts) {
     var msg;
     if ( !targets || !targets.length ) {
@@ -222,7 +211,7 @@ function check(hooks, projectRoot) {
                 d_cur = Q.defer();
             add(h, scratch, [p], {spawnoutput: {stdio: 'ignore'}})
             .then(function() {
-                getVersionFromScript(path.join(scratch, 'platforms', p, 'cordova', 'version'), null)
+                superspawn.maybeSpawn(path.join(scratch, 'platforms', p, 'cordova', 'version'))
                 .then(function(avail) {
                     if (!avail) {
                         /* Platform version script was silent, we can't work with this */
@@ -240,7 +229,7 @@ function check(hooks, projectRoot) {
                 d_avail.resolve('install-failed');
             });
 
-            getVersionFromScript(path.join(projectRoot, 'platforms', p, 'cordova', 'version'), null)
+            superspawn.maybeSpawn(path.join(projectRoot, 'platforms', p, 'cordova', 'version'))
             .then(function(v) {
                 d_cur.resolve(v || '');
             }).catch(function () {
@@ -303,7 +292,7 @@ function list(hooks, projectRoot) {
     .then(function() {
         // Acquire the version number of each platform we have installed, and output that too.
         return Q.all(platforms_on_fs.map(function(p) {
-            return getVersionFromScript(path.join(projectRoot, 'platforms', p, 'cordova', 'version'), null)
+            return superspawn.maybeSpawn(path.join(projectRoot, 'platforms', p, 'cordova', 'version'))
             .then(function(v) {
                 if (!v) return p;
                 return p + ' ' + v;

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/1fba040a/cordova-lib/src/cordova/superspawn.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/superspawn.js b/cordova-lib/src/cordova/superspawn.js
index b35e311..51a4d6b 100644
--- a/cordova-lib/src/cordova/superspawn.js
+++ b/cordova-lib/src/cordova/superspawn.js
@@ -141,3 +141,10 @@ exports.spawn = function(cmd, args, opts) {
     return d.promise;
 };
 
+exports.maybeSpawn = function(cmd, args, opts) {
+    if (fs.existsSync(cmd)) {
+        return exports.spawn(cmd, args, opts);
+    }
+    return Q(null);
+};
+

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/1fba040a/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 376b397..d2508de 100644
--- a/cordova-lib/src/plugman/util/action-stack.js
+++ b/cordova-lib/src/plugman/util/action-stack.js
@@ -25,6 +25,8 @@
 var platforms = require("../platforms"),
     events = require('../../events'),
     Q = require('q');
+var superspawn = require('../../cordova/superspawn');
+var path = require('path');
 
 function ActionStack() {
     this.stack = [];
@@ -96,12 +98,13 @@ ActionStack.prototype = {
         }
         events.emit('verbose', 'Action stack processing complete.');
 
-        if (project_files) {
-            events.emit('verbose', 'Writing out ' + platform + ' project files...');
-            project_files.write();
-        }
-
-        return Q();
+        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);
+            }
+        });
     }
 };
 

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/1fba040a/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 d13bfe9..bedec6b 100644
--- a/cordova-lib/src/plugman/util/android-project.js
+++ b/cordova-lib/src/plugman/util/android-project.js
@@ -29,6 +29,7 @@ var fs = require('fs'),
     path = require('path'),
     properties_parser = require('properties-parser'),
     shell = require('shelljs');
+var semver = require('semver');
 
 
 function addLibraryReference(projectProperties, libraryPath) {
@@ -85,16 +86,22 @@ AndroidProject.prototype = {
         delete this._subProjectDirs[subDir];
         this._dirty = true;
     },
-    write: function () {
+    write: function(platformVersion) {
         if (!this._dirty) return;
 
         for (var filename in this._propertiesEditors) {
             fs.writeFileSync(filename, this._propertiesEditors[filename].toString());
         }
 
-        for (var sub_dir in this._subProjectDirs)
-        {
-            shell.exec('android update lib-project --path "' + sub_dir + '"');
+        // 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) {
+            for (var sub_dir in this._subProjectDirs)
+            {
+                shell.exec('android update lib-project --path "' + sub_dir + '"');
+            }
         }
         this._dirty = false;
     },