use of com.google.devtools.build.xcode.plmerge.proto.PlMergeProtos.Control in project bazel by bazelbuild.
the class PlMerge method main.
public static void main(String[] args) throws OptionsParsingException, IOException {
FileSystem fileSystem = FileSystems.getDefault();
OptionsParser parser = OptionsParser.newOptionsParser(PlMergeOptions.class);
parser.parse(args);
PlMergeOptions options = parser.getOptions(PlMergeOptions.class);
if (options.controlPath == null) {
missingArg("control");
}
InputStream in = Files.newInputStream(fileSystem.getPath(options.controlPath));
Control control = Control.parseFrom(in);
validateControl(control);
PlistMerging merging = PlistMerging.from(control, new KeysToRemoveIfEmptyString("CFBundleIconFile", "NSPrincipalClass"));
String primaryBundleId = Strings.emptyToNull(control.getPrimaryBundleId());
String fallbackBundleId = Strings.emptyToNull(control.getFallbackBundleId());
if (primaryBundleId != null || fallbackBundleId != null) {
// Only set the bundle identifier if we were passed arguments to do so.
// This prevents CFBundleIdentifiers being put into strings files.
merging.setBundleIdentifier(primaryBundleId, fallbackBundleId);
}
Path outputPath = fileSystem.getPath(control.getOutFile());
switch(control.getOutputFormat()) {
case BINARY:
merging.writePlist(outputPath);
break;
case XML:
merging.writeXmlPlist(outputPath);
break;
default:
throw new IllegalArgumentException(String.format("Unknown output format in the control file: %s", control.getOutputFormat()));
}
}
Aggregations