mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-19 07:02:51 +08:00
CB-5793 Add work-around for library references not working with custom output directory (ugh).
This commit is contained in:
parent
7094047b3d
commit
f83d7a7cd1
@ -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() {
|
||||
|
24
bin/templates/cordova/lib/build.js
vendored
24
bin/templates/cordova/lib/build.js
vendored
@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
|
8
bin/templates/cordova/lib/clean.js
vendored
8
bin/templates/cordova/lib/clean.js
vendored
@ -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
bin/templates/project/custom_rules.xml
Normal file
14
bin/templates/project/custom_rules.xml
Normal 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>
|
Loading…
Reference in New Issue
Block a user