use of com.android.tools.build.bundletool.validation.SdkBundleValidator in project bundletool by google.
the class BuildApksCommand method validateSdkBundles.
private void validateSdkBundles(Closer closer) throws IOException {
SdkBundleValidator sdkBundleValidator = SdkBundleValidator.create();
ImmutableSet.Builder<ZipFile> sdkBundleZipsBuilder = ImmutableSet.builder();
for (Path sdkBundlePath : getRuntimeEnabledSdkBundlePaths()) {
sdkBundleZipsBuilder.add(closer.register(new ZipFile(sdkBundlePath.toFile())));
}
ImmutableSet<ZipFile> sdkBundleZips = sdkBundleZipsBuilder.build();
sdkBundleZips.forEach(sdkBundleValidator::validateFile);
ImmutableSet<SdkBundle> sdkBundles = sdkBundleZips.stream().map(sdkBundleZip -> SdkBundle.buildFromZip(sdkBundleZip, /* versionCode= */
0)).collect(toImmutableSet());
sdkBundles.forEach(sdkBundleValidator::validate);
}
use of com.android.tools.build.bundletool.validation.SdkBundleValidator in project bundletool by google.
the class BuildSdkApksCommand method execute.
public void execute() {
validateInput();
try (ZipFile bundleZip = new ZipFile(getSdkBundlePath().toFile());
ZipReader zipReader = ZipReader.createFromFile(getSdkBundlePath());
TempDirectory tempDir = new TempDirectory(getClass().getSimpleName())) {
SdkBundleValidator bundleValidator = SdkBundleValidator.create();
bundleValidator.validateFile(bundleZip);
SdkBundle sdkBundle = SdkBundle.buildFromZip(bundleZip, getVersionCode());
bundleValidator.validate(sdkBundle);
DaggerBuildSdkApksManagerComponent.builder().setBuildSdkApksCommand(this).setTempDirectory(tempDir).setSdkBundle(sdkBundle).setZipReader(zipReader).setUseBundleCompression(false).build().create().execute();
} catch (ZipException e) {
throw InvalidBundleException.builder().withCause(e).withUserMessage("The SDK Bundle is not a valid zip file.").build();
} catch (IOException e) {
throw new UncheckedIOException("An error occurred when validating the Sdk Bundle.", e);
} finally {
if (isExecutorServiceCreatedByBundleTool()) {
getExecutorService().shutdown();
}
}
}
Aggregations