use of com.android.tools.build.bundletool.model.utils.xmlproto.XmlProtoNode in project bundletool by google.
the class ManifestProtoUtils method androidManifestForAssetModule.
public static XmlNode androidManifestForAssetModule(String packageName, ManifestMutator... manifestMutators) {
XmlNode manifestNode = xmlNode(xmlElement("manifest", ImmutableList.of(xmlNamespace("android", ANDROID_NAMESPACE_URI)), ImmutableList.of(xmlAttribute("package", packageName))));
XmlProtoNodeBuilder xmlProtoNode = new XmlProtoNode(manifestNode).toBuilder();
// Default mutators
withTypeAttribute(MODULE_TYPE_ASSET_VALUE).accept(xmlProtoNode.getElement());
withFusingAttribute(true).accept(xmlProtoNode.getElement());
// Additional mutators and overrides of defaults.
for (ManifestMutator manifestMutator : manifestMutators) {
manifestMutator.accept(xmlProtoNode.getElement());
}
// Set a delivery mode if none was set.
if (!AndroidManifest.create(xmlProtoNode.build().getProto()).isDeliveryTypeDeclared()) {
withOnDemandDelivery().accept(xmlProtoNode.getElement());
}
return xmlProtoNode.build().getProto();
}
use of com.android.tools.build.bundletool.model.utils.xmlproto.XmlProtoNode in project bundletool by google.
the class ManifestProtoUtils method androidManifest.
/**
* Creates an Android Manifest.
*
* <p>Without providing any {@code manifestMutator} creates a minimal valid manifest.
*/
public static XmlNode androidManifest(String packageName, ManifestMutator... manifestMutators) {
XmlNode manifestNode = xmlNode(xmlElement("manifest", ImmutableList.of(xmlNamespace("android", ANDROID_NAMESPACE_URI)), ImmutableList.of(xmlAttribute("package", packageName), xmlDecimalIntegerAttribute(ANDROID_NAMESPACE_URI, "versionCode", 0x0101021b, 1))));
XmlProtoNodeBuilder xmlProtoNode = new XmlProtoNode(manifestNode).toBuilder();
withHasCode(false).accept(xmlProtoNode.getElement());
for (ManifestMutator manifestMutator : manifestMutators) {
manifestMutator.accept(xmlProtoNode.getElement());
}
return xmlProtoNode.build().getProto();
}
use of com.android.tools.build.bundletool.model.utils.xmlproto.XmlProtoNode in project bundletool by google.
the class BundleModuleBuilder method build.
public BundleModule build() {
if (androidManifest != null) {
XmlProtoNodeBuilder manifestBuilder = new XmlProtoNode(androidManifest).toBuilder();
boolean hasCode = entries.build().stream().anyMatch(entry -> entry.getPath().toString().endsWith(".dex"));
if (hasCode) {
ManifestProtoUtils.clearHasCode().accept(manifestBuilder.getElement());
}
// Set the 'split' attribute if one is not already set.
if (!moduleName.equals(BundleModuleName.BASE_MODULE_NAME) && !manifestBuilder.getElement().getAttribute("split").isPresent()) {
ManifestProtoUtils.withSplitId(moduleName.getName()).accept(manifestBuilder.getElement());
}
addFile("manifest/AndroidManifest.xml", manifestBuilder.build().getProto().toByteArray());
}
return BundleModule.builder().setName(moduleName).addEntries(entries.build()).setBundleConfig(bundleConfig).build();
}
Aggregations