cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject git commit: Enable platform-specific id for android and ios
Date Tue, 21 Oct 2014 17:18:47 GMT
Repository: cordova-lib
Updated Branches:
  refs/heads/master 58b37f5bf -> 272fad91e


Enable platform-specific id for android and ios

closes #105


Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/272fad91
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/272fad91
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/272fad91

Branch: refs/heads/master
Commit: 272fad91ed99574499f2de570d85d644e4fc8c99
Parents: 58b37f5
Author: SUGA Koji <ko.suga@gmail.com>
Authored: Fri Oct 17 11:46:48 2014 +0900
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Tue Oct 21 13:15:23 2014 -0400

----------------------------------------------------------------------
 cordova-lib/spec-cordova/ConfigParser.spec.js           | 12 ++++++++++++
 .../spec-cordova/metadata/android_parser.spec.js        |  6 ++++++
 cordova-lib/spec-cordova/metadata/ios_parser.spec.js    |  7 +++++++
 cordova-lib/spec-cordova/test-config.xml                |  4 +++-
 cordova-lib/src/configparser/ConfigParser.js            |  6 ++++++
 cordova-lib/src/cordova/metadata/android_parser.js      |  2 +-
 cordova-lib/src/cordova/metadata/ios_parser.js          |  2 +-
 7 files changed, 36 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/272fad91/cordova-lib/spec-cordova/ConfigParser.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/ConfigParser.spec.js b/cordova-lib/spec-cordova/ConfigParser.spec.js
index 7028034..483ce6c 100644
--- a/cordova-lib/spec-cordova/ConfigParser.spec.js
+++ b/cordova-lib/spec-cordova/ConfigParser.spec.js
@@ -53,6 +53,18 @@ describe('config.xml parser', function () {
             });
         });
 
+        describe('package name / android-packageName', function() {
+            it('should get the android packagename', function() {
+                expect(cfg.android_packageName()).toEqual('io.cordova.hellocordova.android');
+            });
+        });
+
+        describe('package name / ios-CFBundleIdentifier', function() {
+            it('should get the ios packagename', function() {
+                expect(cfg.ios_CFBundleIdentifier()).toEqual('io.cordova.hellocordova.ios');
+            });
+        });
+
         describe('version', function() {
             it('should get the version', function() {
                 expect(cfg.version()).toEqual('0.0.1');

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/272fad91/cordova-lib/spec-cordova/metadata/android_parser.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/metadata/android_parser.spec.js b/cordova-lib/spec-cordova/metadata/android_parser.spec.js
index 336d431..0aba397 100644
--- a/cordova-lib/spec-cordova/metadata/android_parser.spec.js
+++ b/cordova-lib/spec-cordova/metadata/android_parser.spec.js
@@ -139,9 +139,15 @@ describe('android project parser', function() {
                 expect(stringsRoot.getroot().find('string').text).toEqual('testname');
             });
             it('should write out the app id to androidmanifest.xml and update the cordova-android
entry Java class', function() {
+                cfg.android_packageName = function () { return null };
                 p.update_from_config(cfg);
                 expect(manifestRoot.getroot().attrib.package).toEqual('testpkg');
             });
+            it('should write out the app id to androidmanifest.xml and update the cordova-android
entry Java class with android_packageName', function() {
+                cfg.android_packageName = function () { return 'testpkg_android' };
+                p.update_from_config(cfg);
+                expect(manifestRoot.getroot().attrib.package).toEqual('testpkg_android');
+            });
             it('should write out the app version to androidmanifest.xml', function() {
                 p.update_from_config(cfg);
                 expect(manifestRoot.getroot().attrib['android:versionName']).toEqual('one
point oh');

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/272fad91/cordova-lib/spec-cordova/metadata/ios_parser.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/metadata/ios_parser.spec.js b/cordova-lib/spec-cordova/metadata/ios_parser.spec.js
index b17ce0d..54fd768 100644
--- a/cordova-lib/spec-cordova/metadata/ios_parser.spec.js
+++ b/cordova-lib/spec-cordova/metadata/ios_parser.spec.js
@@ -117,10 +117,17 @@ describe('ios project parser', function () {
                 });
             });
             it('should write out the app id to info plist as CFBundleIdentifier', function(done)
{
+                cfg.ios_CFBundleIdentifier = function() { return null };
                 wrapper(p.update_from_config(cfg), done, function() {
                     expect(plist_build.mostRecentCall.args[0].CFBundleIdentifier).toEqual('testpkg');
                 });
             });
+            it('should write out the app id to info plist as CFBundleIdentifier with ios-CFBundleIdentifier',
function(done) {
+                cfg.ios_CFBundleIdentifier = function() { return 'testpkg_ios' };
+                wrapper(p.update_from_config(cfg), done, function() {
+                    expect(plist_build.mostRecentCall.args[0].CFBundleIdentifier).toEqual('testpkg_ios');
+                });
+            });
             it('should write out the app version to info plist as CFBundleVersion', function(done)
{
                 wrapper(p.update_from_config(cfg), done, function() {
                     expect(plist_build.mostRecentCall.args[0].CFBundleShortVersionString).toEqual('one
point oh');

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/272fad91/cordova-lib/spec-cordova/test-config.xml
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/test-config.xml b/cordova-lib/spec-cordova/test-config.xml
index 27838b7..1852fb5 100644
--- a/cordova-lib/spec-cordova/test-config.xml
+++ b/cordova-lib/spec-cordova/test-config.xml
@@ -2,7 +2,9 @@
 <widget xmlns     = "http://www.w3.org/ns/widgets"
         xmlns:cdv = "http://cordova.apache.org/ns/1.0"
         id        = "io.cordova.hellocordova"
-        version   = "0.0.1">
+        version   = "0.0.1"
+        android-packageName="io.cordova.hellocordova.android"
+        ios-CFBundleIdentifier="io.cordova.hellocordova.ios">
     <name>Hello Cordova</name>
 
     <description>

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/272fad91/cordova-lib/src/configparser/ConfigParser.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/configparser/ConfigParser.js b/cordova-lib/src/configparser/ConfigParser.js
index f116f81..4a58f42 100644
--- a/cordova-lib/src/configparser/ConfigParser.js
+++ b/cordova-lib/src/configparser/ConfigParser.js
@@ -89,6 +89,12 @@ ConfigParser.prototype = {
     setPackageName: function(id) {
         this.doc.getroot().attrib['id'] = id;
     },
+    android_packageName: function() {
+        return this.doc.getroot().attrib['android-packageName'];
+    },
+    ios_CFBundleIdentifier: function() {
+        return this.doc.getroot().attrib['ios-CFBundleIdentifier'];
+    },
     name: function() {
         return getNodeTextSafe(this.doc.find('name'));
     },

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/272fad91/cordova-lib/src/cordova/metadata/android_parser.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/metadata/android_parser.js b/cordova-lib/src/cordova/metadata/android_parser.js
index 442112d..c2e3270 100644
--- a/cordova-lib/src/cordova/metadata/android_parser.js
+++ b/cordova-lib/src/cordova/metadata/android_parser.js
@@ -226,7 +226,7 @@ module.exports.prototype = {
         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();
+        var pkg = config.android_packageName() || config.packageName();
         pkg = pkg.replace(/-/g, '_'); // Java packages cannot support dashes
         var orig_pkg = manifest.getroot().attrib.package;
         manifest.getroot().attrib.package = pkg;

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/272fad91/cordova-lib/src/cordova/metadata/ios_parser.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/metadata/ios_parser.js b/cordova-lib/src/cordova/metadata/ios_parser.js
index 49e389e..877b68e 100644
--- a/cordova-lib/src/cordova/metadata/ios_parser.js
+++ b/cordova-lib/src/cordova/metadata/ios_parser.js
@@ -60,7 +60,7 @@ module.exports.prototype = {
             return Q.reject(new Error('update_from_config requires a ConfigParser object'));
         }
         var name = config.name();
-        var pkg = config.packageName();
+        var pkg = config.ios_CFBundleIdentifier() || config.packageName();
         var version = config.version();
 
         // Update package id (bundle id)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message