cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject android commit: CB-5793 Add work-around for library references not working with custom output directory (ugh).
Date Tue, 21 Jan 2014 20:09:52 GMT
Updated Branches:
  refs/heads/master 7094047b3 -> f83d7a7cd


CB-5793 Add work-around for library references not working with custom output directory (ugh).


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

Branch: refs/heads/master
Commit: f83d7a7cd1c31bb0a61e3571e20e9a42684aa749
Parents: 7094047
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Tue Jan 21 15:09:15 2014 -0500
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Tue Jan 21 15:09:15 2014 -0500

----------------------------------------------------------------------
 bin/lib/create.js                      |  7 +++++++
 bin/templates/cordova/lib/build.js     | 24 ++++++++++++++++++++++--
 bin/templates/cordova/lib/clean.js     |  8 ++++----
 bin/templates/project/custom_rules.xml | 14 ++++++++++++++
 4 files changed, 47 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/f83d7a7c/bin/lib/create.js
----------------------------------------------------------------------
diff --git a/bin/lib/create.js b/bin/lib/create.js
index 0ca877c..bd0e2f1 100755
--- a/bin/lib/create.js
+++ b/bin/lib/create.js
@@ -87,6 +87,11 @@ function runAndroidUpdate(projectPath, target_api, shared) {
     return exec('android update project --subprojects --path "' + projectPath + '" --target
' + target_api + ' --library "' + path.relative(projectPath, targetFrameworkDir) + '"');
 }
 
+function copyAntRules(projectPath) {
+    var srcDir = path.join(ROOT, 'bin', 'templates', 'project');
+    shell.cp('-f', path.join(srcDir, 'custom_rules.xml'), projectPath);
+}
+
 function copyScripts(projectPath) {
     var srcScriptsDir = path.join(ROOT, 'bin', 'templates', 'cordova');
     var destScriptsDir = path.join(projectPath, 'cordova');
@@ -186,6 +191,7 @@ exports.createProject = function(project_path, package_name, project_name,
proje
             shell.sed('-i', /__PACKAGE__/, package_name, manifest_path);
             shell.sed('-i', /__APILEVEL__/, target_api.split('-')[1], manifest_path);
             copyScripts(project_path);
+            copyAntRules(project_path);
         });
         // Link it to local android install.
         return runAndroidUpdate(project_path, target_api, use_shared_project);
@@ -209,6 +215,7 @@ exports.updateProject = function(projectPath) {
         var target_api = check_reqs.get_target();
         copyJsAndLibrary(projectPath, false, null);
         copyScripts(projectPath);
+        copyAntRules(projectPath);
         removeDebuggableFromManifest(projectPath);
         return runAndroidUpdate(projectPath, target_api, false)
         .then(function() {

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/f83d7a7c/bin/templates/cordova/lib/build.js
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/lib/build.js b/bin/templates/cordova/lib/build.js
index 5e8ce0a..7e0df2f 100644
--- a/bin/templates/cordova/lib/build.js
+++ b/bin/templates/cordova/lib/build.js
@@ -26,6 +26,19 @@ var shell   = require('shelljs'),
     fs      = require('fs'),
     ROOT    = path.join(__dirname, '..', '..');
 
+
+function hasCustomRules() {
+    return fs.existsSync(path.join(ROOT, 'custom_rules.xml'));
+}
+module.exports.getAntArgs = function(cmd) {
+    var args = [cmd, '-f', path.join(ROOT, 'build.xml')];
+    // custom_rules.xml is required for incremental builds.
+    if (hasCustomRules()) {
+        args.push('-Dout.dir=ant-build', '-Dgen.absolute.dir=ant-gen');
+    }
+    return args;
+};
+
 /*
  * Builds the project with ant.
  * Returns a promise.
@@ -33,7 +46,7 @@ var shell   = require('shelljs'),
 module.exports.run = function(build_type) {
     //default build type
     build_type = typeof build_type !== 'undefined' ? build_type : "--debug";
-    var args = ['debug', '-f', path.join(ROOT, 'build.xml'), '-Dout.dir=ant-build', '-Dgen.dir=ant-build/gen'];
+    var args = module.exports.getAntArgs('debug');
     switch(build_type) {
         case '--debug' :
             break;
@@ -46,7 +59,14 @@ module.exports.run = function(build_type) {
         default :
             return Q.reject('Build option \'' + build_type + '\' not recognized.');
     }
-    return spawn('ant', args);
+    // Without our custom_rules.xml, we need to clean before building.
+    var ret = Q();
+    if (!hasCustomRules()) {
+        ret = require('./clean').run();
+    }
+    return ret.then(function() {
+        return spawn('ant', args);
+    });
 }
 
 /*

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/f83d7a7c/bin/templates/cordova/lib/clean.js
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/lib/clean.js b/bin/templates/cordova/lib/clean.js
index f86cfb8..0a2e0ce 100644
--- a/bin/templates/cordova/lib/clean.js
+++ b/bin/templates/cordova/lib/clean.js
@@ -19,16 +19,16 @@
        under the License.
 */
 
-var spawn = require('./spawn'),
-    path  = require('path'),
-    ROOT  = path.join(__dirname, '..', '..');
+var build = require('./build'),
+    spawn = require('./spawn'),
+    path  = require('path');
 
 /*
  * Cleans the project using ant
  * Returns a promise.
  */
 module.exports.run = function() {
-    var args = ['clean', '-f', path.join(ROOT, 'build.xml'), '-Dout.dir=ant-build', '-Dgen.dir=ant-build/gen'];
+    var args = build.getAntArgs('clean');
     return spawn('ant', args);
 }
 

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/f83d7a7c/bin/templates/project/custom_rules.xml
----------------------------------------------------------------------
diff --git a/bin/templates/project/custom_rules.xml b/bin/templates/project/custom_rules.xml
new file mode 100644
index 0000000..51434ac
--- /dev/null
+++ b/bin/templates/project/custom_rules.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+    <target name="-pre-compile">
+        <!-- Fix library references due to bug in build.xml: See: https://groups.google.com/forum/#!topic/android-developers/0ivH-YqCjzg
-->
+        <pathconvert property="fixedJarsPath" refid="project.all.jars.path">
+          <filtermapper>
+            <replacestring from="/bin/" to="/ant-build/"/>
+          </filtermapper>
+        </pathconvert>
+        <path id="project.all.jars.path">
+          <pathelement path="${fixedJarsPath}"/>
+        </path>
+    </target>
+</project>


Mime
View raw message