diff options
author | Googler <noreply@google.com> | 2015-04-28 15:07:23 +0000 |
---|---|---|
committer | Kristina Chodorow <kchodorow@google.com> | 2015-04-28 15:16:07 +0000 |
commit | 67944d866d4b74b9c4af51d5097a51fed5a6c30e (patch) | |
tree | 5ac5174c09737710c4cf933ef81fd2c5da1dab07 /src/objc_tools | |
parent | cd687072a3f37dd730ac13bc827c5bb2eb4dc90a (diff) |
Add flags primary_bundle_id and fallback_bundle_id to PlMerge to set bundle identifiers. Also allow users to use bundle identifiers specified in BUILD files via "bundle_id" attribute on objc bundling rules to override the ones from plist files.
RELNOTES: bundle_id attribute on objc_* rules now overrides plist bundle id".
--
MOS_MIGRATED_REVID=92247814
Diffstat (limited to 'src/objc_tools')
-rw-r--r-- | src/objc_tools/plmerge/java/com/google/devtools/build/xcode/plmerge/PlMerge.java | 16 | ||||
-rw-r--r-- | src/objc_tools/plmerge/java/com/google/devtools/build/xcode/plmerge/PlistMerging.java | 25 |
2 files changed, 25 insertions, 16 deletions
diff --git a/src/objc_tools/plmerge/java/com/google/devtools/build/xcode/plmerge/PlMerge.java b/src/objc_tools/plmerge/java/com/google/devtools/build/xcode/plmerge/PlMerge.java index e61f2b908a..a367e57d6d 100644 --- a/src/objc_tools/plmerge/java/com/google/devtools/build/xcode/plmerge/PlMerge.java +++ b/src/objc_tools/plmerge/java/com/google/devtools/build/xcode/plmerge/PlMerge.java @@ -53,6 +53,21 @@ public class PlMerge { help = "Path to the output file. Required.", defaultValue = "null") public String outFile; + + @Option( + name = "primary_bundle_id", + help = "A reverse-DNS string identifier for this bundle associated with output binary " + + "plist. This flag overrides the bundle id specified in field CFBundleIdentifier in " + + "the associated plist file.", + defaultValue = "null") + public String primaryBundleId; + + @Option( + name = "fallback_bundle_id", + help = "A fallback reverse-DNS string identifier for this bundle when the bundle " + + "identifier is not specified in flag primary_bundle_id or associated plist file", + defaultValue = "null") + public String fallbackBundleId; } public static void main(String[] args) throws IOException, OptionsParsingException { @@ -74,6 +89,7 @@ public class PlMerge { PlistMerging merging = PlistMerging.from(sourceFilePaths, ImmutableMap.<String, NSObject>of(), ImmutableMap.<String, String>of(), new KeysToRemoveIfEmptyString()); + merging.setBundleIdentifier(options.primaryBundleId, options.fallbackBundleId); merging.writePlist(fileSystem.getPath(options.outFile)); } diff --git a/src/objc_tools/plmerge/java/com/google/devtools/build/xcode/plmerge/PlistMerging.java b/src/objc_tools/plmerge/java/com/google/devtools/build/xcode/plmerge/PlistMerging.java index 558cf466f6..56632993dd 100644 --- a/src/objc_tools/plmerge/java/com/google/devtools/build/xcode/plmerge/PlistMerging.java +++ b/src/objc_tools/plmerge/java/com/google/devtools/build/xcode/plmerge/PlistMerging.java @@ -263,28 +263,21 @@ public class PlistMerging extends Value<PlistMerging> { * Sets the given identifier on this merged plist in the {@code CFBundleIdentifier} * attribute. * - * @param primaryIdentifier used if the bundle doesn't have an identifier already, can be null - * @param fallbackIdentifier used if neither bundle, nor primary identifier is set, can be null + * @param primaryIdentifier used to set the bundle identifier or override the existing one from + * plist file, can be null + * @param fallbackIdentifier used to set the bundle identifier if it is not set by plist file or + * primary identifier, can be null * @return this plist merging - * @throws ValidationException if both plist and control contain bundle identifiers and they - * don't match */ public PlistMerging setBundleIdentifier(String primaryIdentifier, String fallbackIdentifier) { NSString bundleIdentifier = (NSString) merged.get(BUNDLE_IDENTIFIER_PLIST_KEY); - if (bundleIdentifier == null) { - if (primaryIdentifier != null) { - merged.put(BUNDLE_IDENTIFIER_PLIST_KEY, primaryIdentifier); - } else if (fallbackIdentifier != null) { - merged.put(BUNDLE_IDENTIFIER_PLIST_KEY, fallbackIdentifier); - } - } else if (primaryIdentifier != null - && !primaryIdentifier.equals(bundleIdentifier.getContent())) { - throw new ValidationException(String.format( - "Blaze generated bundle_id is %s but the Plist %s is %s", - primaryIdentifier, BUNDLE_IDENTIFIER_PLIST_KEY, bundleIdentifier)); + if (primaryIdentifier != null) { + merged.put(BUNDLE_IDENTIFIER_PLIST_KEY, primaryIdentifier); + } else if (bundleIdentifier == null && fallbackIdentifier != null) { + merged.put(BUNDLE_IDENTIFIER_PLIST_KEY, fallbackIdentifier); } - + return this; } |