Search in sources :

Example 1 with BundleMetadata

use of com.android.tools.build.bundletool.model.BundleMetadata in project bundletool by google.

the class BundleParser method readBundleMetadata.

/**
 * Loads BUNDLE-METADATA into {@link BundleMetadata}
 */
public static BundleMetadata readBundleMetadata(ZipFile bundleFile) {
    BundleMetadata.Builder metadata = BundleMetadata.builder();
    ZipUtils.allFileEntries(bundleFile).filter(entry -> ZipPath.create(entry.getName()).startsWith(METADATA_DIRECTORY)).forEach(zipEntry -> {
        ZipPath bundlePath = ZipPath.create(zipEntry.getName());
        // Strip the top-level metadata directory.
        ZipPath metadataPath = bundlePath.subpath(1, bundlePath.getNameCount());
        metadata.addFile(metadataPath, ZipUtils.asByteSource(bundleFile, zipEntry));
    });
    return metadata.build();
}
Also used : BundleModuleName(com.android.tools.build.bundletool.model.BundleModuleName) ZipPath(com.android.tools.build.bundletool.model.ZipPath) Enumeration(java.util.Enumeration) CheckReturnValue(com.google.errorprone.annotations.CheckReturnValue) HashMap(java.util.HashMap) ImmutableList(com.google.common.collect.ImmutableList) Map(java.util.Map) ImmutableSet.toImmutableSet(com.google.common.collect.ImmutableSet.toImmutableSet) ZipFile(java.util.zip.ZipFile) ModuleEntryBundleLocation(com.android.tools.build.bundletool.model.ModuleEntry.ModuleEntryBundleLocation) ZipEntry(java.util.zip.ZipEntry) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) ImmutableSet(com.google.common.collect.ImmutableSet) InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) Collection(java.util.Collection) IOException(java.io.IOException) BundleMetadata(com.android.tools.build.bundletool.model.BundleMetadata) ClassesDexNameSanitizer(com.android.tools.build.bundletool.model.ClassesDexNameSanitizer) UncheckedIOException(java.io.UncheckedIOException) BundleConfig(com.android.bundle.Config.BundleConfig) Paths(java.nio.file.Paths) ModuleEntry(com.android.tools.build.bundletool.model.ModuleEntry) Optional(java.util.Optional) BundleModule(com.android.tools.build.bundletool.model.BundleModule) ZipPath(com.android.tools.build.bundletool.model.ZipPath) BundleMetadata(com.android.tools.build.bundletool.model.BundleMetadata)

Aggregations

BundleConfig (com.android.bundle.Config.BundleConfig)1 BundleMetadata (com.android.tools.build.bundletool.model.BundleMetadata)1 BundleModule (com.android.tools.build.bundletool.model.BundleModule)1 BundleModuleName (com.android.tools.build.bundletool.model.BundleModuleName)1 ClassesDexNameSanitizer (com.android.tools.build.bundletool.model.ClassesDexNameSanitizer)1 ModuleEntry (com.android.tools.build.bundletool.model.ModuleEntry)1 ModuleEntryBundleLocation (com.android.tools.build.bundletool.model.ModuleEntry.ModuleEntryBundleLocation)1 ZipPath (com.android.tools.build.bundletool.model.ZipPath)1 InvalidBundleException (com.android.tools.build.bundletool.model.exceptions.InvalidBundleException)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 ImmutableSet.toImmutableSet (com.google.common.collect.ImmutableSet.toImmutableSet)1 CheckReturnValue (com.google.errorprone.annotations.CheckReturnValue)1 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1 IOException (java.io.IOException)1 UncheckedIOException (java.io.UncheckedIOException)1 Paths (java.nio.file.Paths)1 Collection (java.util.Collection)1 Enumeration (java.util.Enumeration)1