You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ka...@apache.org on 2014/04/16 17:45:59 UTC
git commit: CB-5093: Add versionCode and CFBundleVersion during
prepare
Repository: cordova-cli
Updated Branches:
refs/heads/master 3a4a9ebda -> 396b4f962
CB-5093: Add versionCode and CFBundleVersion during prepare
The version can be given as part of the <widget> tag.
Example:
<widget
id="io.cordova.hellocordova" version="0.0.1"
android-versionCode="7"
ios-CFBundleVersion="3.3.3"
...
If not specified in the widget tag, the following defaults will be used.
Assuming version = "MAJOR.MINOR.PATCH-whatever"
versionCode = PATCH + MINOR * 100 + MAJOR * 10000
CFBundleVersion = "MAJOR.MINOR.PATCH"
Not adding the "other" version for windows platforms at this stage.
It's is in
Properties/AssemblyInfo.cs which we currently don't modify.
[assembly: AssemblyVersion("1.0.0.0")]
For more info about the "other" versions see:
http://developer.android.com/tools/publishing/versioning.html
http://stackoverflow.com/questions/4933093/cfbundleversion-in-the-info-plist-upload-error
Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/396b4f96
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/396b4f96
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/396b4f96
Branch: refs/heads/master
Commit: 396b4f9628db3faa022cea1a18dd57fd8da13964
Parents: 3a4a9eb
Author: Mark Koudritsky <ka...@gmail.com>
Authored: Tue Apr 15 23:48:15 2014 -0400
Committer: Mark Koudritsky <ka...@gmail.com>
Committed: Wed Apr 16 11:36:04 2014 -0400
----------------------------------------------------------------------
src/ConfigParser.js | 6 ++++++
src/metadata/android_parser.js | 12 ++++++++++++
src/metadata/ios_parser.js | 11 ++++++++++-
3 files changed, 28 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/396b4f96/src/ConfigParser.js
----------------------------------------------------------------------
diff --git a/src/ConfigParser.js b/src/ConfigParser.js
index 36adc0c..edbb01f 100644
--- a/src/ConfigParser.js
+++ b/src/ConfigParser.js
@@ -73,6 +73,12 @@ ConfigParser.prototype = {
version: function() {
return this.doc.getroot().attrib['version'];
},
+ android_versionCode: function() {
+ return this.doc.getroot().attrib['android-versionCode'];
+ },
+ ios_CFBundleVersion: function() {
+ return this.doc.getroot().attrib['ios-CFBundleVersion'];
+ },
setVersion: function(value) {
this.doc.getroot().attrib['version'] = value;
},
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/396b4f96/src/metadata/android_parser.js
----------------------------------------------------------------------
diff --git a/src/metadata/android_parser.js b/src/metadata/android_parser.js
index 51b5aa7..bead421 100644
--- a/src/metadata/android_parser.js
+++ b/src/metadata/android_parser.js
@@ -73,7 +73,9 @@ module.exports.prototype = {
var manifest = xml.parseElementtreeSync(this.manifest);
// Update the version by changing the AndroidManifest android:versionName
var version = config.version();
+ var versionCode = config.android_versionCode() || default_versionCode(version);
manifest.getroot().attrib["android:versionName"] = version;
+ manifest.getroot().attrib["android:versionCode"] = versionCode;
// Update package name by changing the AndroidManifest id and moving the entry class around to the proper package directory
var pkg = config.packageName();
@@ -175,3 +177,13 @@ module.exports.prototype = {
return Q();
}
};
+
+
+// Consturct the default value for versionCode as
+// PATCH + MINOR * 100 + MAJOR * 10000
+// see http://developer.android.com/tools/publishing/versioning.html
+function default_versionCode(version) {
+ nums = version.split('-')[0].split('.').map(Number);
+ var versionCode = nums[0] * 10000 + nums[1] * 100 + nums[2];
+ return versionCode;
+}
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/396b4f96/src/metadata/ios_parser.js
----------------------------------------------------------------------
diff --git a/src/metadata/ios_parser.js b/src/metadata/ios_parser.js
index ae3280a..c50f15f 100644
--- a/src/metadata/ios_parser.js
+++ b/src/metadata/ios_parser.js
@@ -16,6 +16,7 @@
specific language governing permissions and limitations
under the License.
*/
+
var fs = require('fs'),
path = require('path'),
xcode = require('xcode'),
@@ -67,7 +68,8 @@ module.exports.prototype = {
// Update version (bundle version)
infoPlist['CFBundleShortVersionString'] = version;
- // TODO: add a way to update infoPlist['CFBundleVersion'].
+ var CFBundleVersion = config.ios_CFBundleVersion() || default_CFBundleVersion(version);
+ infoPlist['CFBundleVersion'] = CFBundleVersion;
var info_contents = plist.build(infoPlist);
info_contents = info_contents.replace(/<string>[\s\r\n]*<\/string>/g,'<string></string>');
@@ -159,3 +161,10 @@ module.exports.prototype = {
});
}
};
+
+
+// Construct a default value for CFBundleVersion as the version with any
+// -rclabel stripped=.
+function default_CFBundleVersion(version) {
+ return version.split('-')[0];
+}