use of com.android.tools.build.bundletool.model.SdkBundle in project bundletool by google.
the class ApkSerializerManager method serializeSdkApkSetContent.
private BuildSdkApksResult serializeSdkApkSetContent(Path outputDirectory, GeneratedApks generatedApks) {
ImmutableList<Variant> allVariantsWithTargeting = serializeApks(outputDirectory, generatedApks, /* deviceSpec= */
Optional.empty());
SdkBundle sdkBundle = (SdkBundle) bundle;
return BuildSdkApksResult.newBuilder().setPackageName(sdkBundle.getPackageName()).addAllVariant(allVariantsWithTargeting).setBundletool(Bundletool.newBuilder().setVersion(BundleToolVersion.getCurrentVersion().toString())).setVersion(SdkVersionInformation.newBuilder().setVersionCode(sdkBundle.getVersionCode()).setMajor(Long.parseLong(sdkBundle.getMajorVersion())).setPatch(Long.parseLong(sdkBundle.getPatchVersion())).build()).build();
}
use of com.android.tools.build.bundletool.model.SdkBundle in project bundletool by google.
the class BuildSdkApksManagerTest method sdkManifestMutation_patchVersionNotSet_defaultPatchVersionAdded.
@Test
public void sdkManifestMutation_patchVersionNotSet_defaultPatchVersionAdded() throws Exception {
SdkBundle sdkBundle = new SdkBundleBuilder().setModule(new BundleModuleBuilder("base").setManifest(androidManifest(PACKAGE_NAME, withSdkLibraryElement("20"))).build()).build();
execute(sdkBundle);
ZipFile apkSetFile = new ZipFile(outputFilePath.toFile());
BuildSdkApksResult result = extractTocFromSdkApkSetFile(apkSetFile, tmpDir);
Variant variant = result.getVariant(0);
ApkDescription apkDescription = variant.getApkSet(0).getApkDescription(0);
File apkFile = extractFromApkSetFile(apkSetFile, apkDescription.getPath(), tmpDir);
AndroidManifest manifest = extractAndroidManifest(apkFile, tmpDir);
assertThat(manifest.getMetadataValue(SDK_PATCH_VERSION_ATTRIBUTE_NAME)).hasValue(DEFAULT_SDK_PATCH_VERSION);
}
Aggregations