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/14 05:08:27 UTC

[07/11] android commit: [CB-3542] Only update framework/ project when building the jar.

[CB-3542] Only update framework/ project when building the jar.

No need to do it during every check_reqs.
This also extracts the jar building into a helper function.


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

Branch: refs/heads/master
Commit: dd3c261ba29f2c69c3febdd035307eca099ef4cb
Parents: 70cc711
Author: Andrew Grieve <ag...@chromium.org>
Authored: Fri Sep 13 21:38:46 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri Sep 13 22:49:14 2013 -0400

----------------------------------------------------------------------
 bin/lib/check_reqs.js |  9 +--------
 bin/lib/create.js     | 26 +++++++++++++++-----------
 2 files changed, 16 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/dd3c261b/bin/lib/check_reqs.js
----------------------------------------------------------------------
diff --git a/bin/lib/check_reqs.js b/bin/lib/check_reqs.js
index eb0c477..c064499 100644
--- a/bin/lib/check_reqs.js
+++ b/bin/lib/check_reqs.js
@@ -69,17 +69,10 @@ module.exports.check_android = function() {
     } else if(!targets.output.match(valid_target)) {
         console.error('Please install Android target ' + valid_target.split('-')[1] + ' (the Android newest SDK). Make sure you have the latest Android tools installed as well. Run \"android\" from your command-line to install/update any missing SDKs or tools.');
         return false;
-    } else {
-        var cmd = 'android update project -p ' + ROOT + ' -t ' + valid_target + ' 1> /dev/null 2>&1';
-        var result = shell.exec(cmd, {silent:false, async:true});
-        if(result.code > 0) {
-          console.error('Error updating the Cordova library to work with your Android environment.');
-          return false;
-        }
     }
     return true;
 }
 
 module.exports.run = function() {
     return this.check_ant() && this.check_java && this.check_android();
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/dd3c261b/bin/lib/create.js
----------------------------------------------------------------------
diff --git a/bin/lib/create.js b/bin/lib/create.js
index c419c73..3a486f3 100755
--- a/bin/lib/create.js
+++ b/bin/lib/create.js
@@ -47,6 +47,20 @@ function exec(command) {
     }
 }
 
+function ensureJarIsBuilt(version, target_api) {
+    if (!fs.existsSync(path.join(ROOT, 'framework', 'cordova-' + version + '.jar')) && fs.existsSync(path.join(ROOT, 'framework'))) {
+        var valid_target = check_reqs.get_target();
+        console.log('Building jar');
+        // update the cordova-android framework for the desired target
+        exec('android --silent update lib-project --target "' + target_api + '" --path "' + path.join(ROOT, 'framework') + '"');
+        // compile cordova.js and cordova.jar
+        var cwd = process.cwd();
+        process.chdir(path.join(ROOT, 'framework'));
+        exec('ant jar');
+        process.chdir(cwd);
+    }
+};
+
 /**
  * $ create [options]
  *
@@ -104,17 +118,7 @@ module.exports.run = function(project_path, package_name, project_name, project_
     console.log('\tAndroid target : ' + target_api);
 
     // build from source. distro should have these files
-    if(!fs.existsSync(path.join(ROOT, 'framework', 'cordova-' + VERSION + '.jar')) && fs.existsSync(path.join(ROOT, 'framework'))) {
-        console.log('Building jar and js files...');
-        // update the cordova-android framework for the desired target
-        exec('android update project --target ' + target_api + ' --path ' + path.join(ROOT, 'framework'));
-
-        // compile cordova.js and cordova.jar
-        var cwd = process.cwd();
-        process.chdir(path.join(ROOT, 'framework'));
-        exec('ant jar');
-        process.chdir(cwd);
-    }
+    ensureJarIsBuilt(VERSION, target_api);
 
     // create new android project
     var create_cmd = 'android create project --target "'+target_api+'" --path "'+path.relative(process.cwd(), project_path)+'" --package "'+package_name+'" --activity "'+safe_activity_name+'"';