You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by na...@apache.org on 2014/02/03 21:26:22 UTC

[21/32] git commit: CB-5793 Add work-around for library references not working with custom output directory (ugh).

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-amazon-fireos/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/commit/6d8da4b2
Tree: http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/tree/6d8da4b2
Diff: http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/diff/6d8da4b2

Branch: refs/heads/3.4.x
Commit: 6d8da4b2b7828a59dabc13f183c3922bae88fe41
Parents: 6cc9923
Author: Andrew Grieve <ag...@chromium.org>
Authored: Tue Jan 21 15:09:15 2014 -0500
Committer: Archana Naik <na...@lab126.com>
Committed: Mon Feb 3 11:09:46 2014 -0800

----------------------------------------------------------------------
 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-amazon-fireos/blob/6d8da4b2/bin/lib/create.js
----------------------------------------------------------------------
diff --git a/bin/lib/create.js b/bin/lib/create.js
index c542ab8..42b58d3 100755
--- a/bin/lib/create.js
+++ b/bin/lib/create.js
@@ -76,6 +76,11 @@ function copyJsAndJar(projectPath, version) {
     shell.cp('-f', path.join(ROOT, 'framework', 'libs','awv_interface.jar'), path.join(projectPath, 'libs', 'awv_interface.jar'));
 }
 
+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');
@@ -178,6 +183,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.
         console.log('Running "android update project"');
@@ -204,6 +210,7 @@ exports.updateProject = function(projectPath) {
     }).then(function() {
         copyJsAndJar(projectPath, version);
         copyScripts(projectPath);
+        copyAntRules(projectPath);
         removeDebuggableFromManifest(projectPath);
         return runAndroidUpdate(projectPath, target_api, false)
         .then(function() {

http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/blob/6d8da4b2/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-amazon-fireos/blob/6d8da4b2/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-amazon-fireos/blob/6d8da4b2/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>