use of com.android.bundle.Commands.ExtractedApk in project bundletool by google.
the class ExtractApksCommand method produceCommandMetadata.
private static void produceCommandMetadata(ImmutableList<GeneratedApk> generatedApks, BuildApksResult toc, Path outputDir) {
ImmutableList<ExtractedApk> apks = generatedApks.stream().map(apk -> ExtractedApk.newBuilder().setPath(apk.getPath().getFileName().toString()).setModuleName(apk.getModuleName()).setDeliveryType(apk.getDeliveryType()).build()).collect(toImmutableList());
try {
JsonFormat.Printer printer = JsonFormat.printer();
ExtractApksResult.Builder builder = ExtractApksResult.newBuilder();
if (toc.getLocalTestingInfo().getEnabled()) {
builder.setLocalTestingInfo(createLocalTestingInfo(toc));
}
String metadata = printer.print(builder.addAllApks(apks).build());
Files.write(outputDir.resolve(METADATA_FILE), metadata.getBytes(UTF_8));
} catch (IOException e) {
throw new UncheckedIOException("Error while writing metadata.json.", e);
}
}
Aggregations