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

This commit is contained in:
Andrew Grieve
2014-01-21 15:09:15 -05:00
parent 7094047b3d
commit f83d7a7cd1
4 changed files with 47 additions and 6 deletions
+22 -2
View File
@@ -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);
});
}
/*
+4 -4
View File
@@ -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);
}
+14
View File
@@ -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>