CB-9428 update script now bumps up minSdkVersion to 14 if it is less than that.

This commit is contained in:
Steve Gill 2015-07-31 16:32:41 -07:00
parent e5506d40bc
commit 8f7bc1ffbb

View File

@ -290,12 +290,31 @@ function extractProjectNameFromManifest(projectPath) {
return m[1]; return m[1];
} }
// Cordova-android updates sometimes drop support for older versions. Need to update minSDK in existing projects.
function updateMinSDKInManifest(projectPath) {
var manifestPath = path.join(projectPath, 'AndroidManifest.xml');
var manifestData = fs.readFileSync(manifestPath, 'utf8');
var minSDKVersion = 14;
//grab minSdkVersion from Android.
var m = /android:minSdkVersion\s*=\s*"(.*?)"/i.exec(manifestData);
if (!m) {
throw new Error('Could not find minSDKVersion in ' + manifestPath);
}
//if minSDKVersion in Android.manifest is less than our current min, replace it
if(Number(m[1]) < minSDKVersion) {
console.log('Updating minSdkVersion from ' + m[1] + ' to ' + minSDKVersion + ' in AndroidManifest.xml');
shell.sed('-i', /android:minSdkVersion\s*=\s*"(.*?)"/, 'android:minSdkVersion="'+minSDKVersion+'"', manifestPath);
}
}
// Returns a promise. // Returns a promise.
exports.updateProject = function(projectPath, shared) { exports.updateProject = function(projectPath, shared) {
return Q() return Q()
.then(function() { .then(function() {
var projectName = extractProjectNameFromManifest(projectPath); var projectName = extractProjectNameFromManifest(projectPath);
var target_api = check_reqs.get_target(); var target_api = check_reqs.get_target();
updateMinSDKInManifest(projectPath);
copyJsAndLibrary(projectPath, shared, projectName); copyJsAndLibrary(projectPath, shared, projectName);
copyScripts(projectPath); copyScripts(projectPath);
copyBuildRules(projectPath); copyBuildRules(projectPath);