Search in sources :

Example 1 with BundleConfigValidator

use of com.android.tools.build.bundletool.validation.BundleConfigValidator in project bundletool by google.

the class AppBundleRecompressor method extractBundleConfig.

private static BundleConfig extractBundleConfig(ZipReader zipReader) {
    // The bundle hasn't been validated yet, therefore selected validations need to be run manually.
    if (!zipReader.getEntry(AppBundle.BUNDLE_CONFIG_FILE_NAME).isPresent()) {
        throw InvalidBundleException.builder().withUserMessage("The archive doesn't seem to be an App Bundle, it is missing required file '%s'.", AppBundle.BUNDLE_CONFIG_FILE_NAME).build();
    }
    try (InputStream inputStream = zipReader.getUncompressedPayload(AppBundle.BUNDLE_CONFIG_FILE_NAME)) {
        BundleConfig bundleConfig = BundleConfig.parseFrom(inputStream, ExtensionRegistryLite.getEmptyRegistry());
        new BundleConfigValidator().validateCompression(bundleConfig.getCompression());
        return bundleConfig;
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
Also used : BundleConfig(com.android.bundle.Config.BundleConfig) InputStream(java.io.InputStream) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException) BundleConfigValidator(com.android.tools.build.bundletool.validation.BundleConfigValidator)

Aggregations

BundleConfig (com.android.bundle.Config.BundleConfig)1 BundleConfigValidator (com.android.tools.build.bundletool.validation.BundleConfigValidator)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 UncheckedIOException (java.io.UncheckedIOException)1