public static Version getVersionFromBundleConfig(BundleConfig bundleConfig) { String rawVersion = bundleConfig.getBundletool().getVersion(); // Legacy. Remove soon and fail. if (Strings.isNullOrEmpty(rawVersion)) { return Version.of("0.0.0"); } return Version.of(rawVersion); } }
.toBuilder() .setBundletool( Bundletool.newBuilder() .setVersion(BundleToolVersion.getCurrentVersion().toString())) .build();
.addAllVariant(allVariantsWithTargeting) .setBundletool( Bundletool.newBuilder() .setVersion(BundleToolVersion.getCurrentVersion().toString())) .build());
BundleConfig bundleConfig, ImmutableSet<OptimizationDimension> optimizationsOverride) { String buildVersionString = bundleConfig.getBundletool().getVersion(); Version bundleToolBuildVersion = buildVersionString.isEmpty()
@Test public void bundleConfig_saved() throws Exception { Path module = createSimpleBaseModule(); // Any version supplied by the user is ignored and overwritten. BundleConfig bundleConfigFromUser = BundleConfigBuilder.create().setVersion("0.0.0").build(); BundleConfig bundleConfigInBundle = new BundleConfigBuilder(bundleConfigFromUser) .setVersion(BundleToolVersion.getCurrentVersion().toString()) .build(); assertThat(bundleConfigFromUser.getBundletool().getVersion()) .isNotEqualTo(bundleConfigInBundle.getBundletool().getVersion()); BuildBundleCommand.builder() .setModulesPaths(ImmutableList.of(module)) .setOutputPath(bundlePath) .setBundleConfig(bundleConfigFromUser) .build() .execute(); AppBundle appBundle = AppBundle.buildFromZip(new ZipFile(bundlePath.toFile())); assertThat(appBundle.getBundleConfig()).isEqualTo(bundleConfigInBundle); }
@Test public void bundleToolVersionSet() throws Exception { AppBundle appBundle = new AppBundleBuilder() .addModule("base", builder -> builder.setManifest(androidManifest("com.test.app"))) .build(); bundleSerializer.writeToDisk(appBundle, bundlePath); BuildApksCommand command = BuildApksCommand.builder() .setBundlePath(bundlePath) .setOutputFile(outputFilePath) .setAapt2Command(aapt2Command) .build(); Path apkSetFilePath = execute(command); ZipFile apkSetFile = new ZipFile(apkSetFilePath.toFile()); BuildApksResult result = extractTocFromApkSetFile(apkSetFile, outputDir); assertThat(result.getBundletool().getVersion()) .isEqualTo(BundleToolVersion.getCurrentVersion().toString()); }
public BundleConfigBuilder setVersion(String versionString) { builder.setBundletool(Bundletool.newBuilder().setVersion(versionString)); return this; }
@Test public void bundleToolVersionSet() throws Exception { Path module = createSimpleBaseModule(); BuildBundleCommand.builder() .setModulesPaths(ImmutableList.of(module)) .setOutputPath(bundlePath) .build() .execute(); AppBundle appBundle = AppBundle.buildFromZip(new ZipFile(bundlePath.toFile())); assertThat(appBundle.getBundleConfig().getBundletool().getVersion()) .isEqualTo(BundleToolVersion.getCurrentVersion().toString()); }