use of com.android.tools.build.bundletool.flags.FlagParser in project bundletool by google.
the class BuildApksCommandTest method buildingViaFlagsAndBuilderHasSameResult_optionalOutputFormat.
@Test
public void buildingViaFlagsAndBuilderHasSameResult_optionalOutputFormat() throws Exception {
ByteArrayOutputStream output = new ByteArrayOutputStream();
BuildApksCommand commandViaFlags = BuildApksCommand.fromFlags(new FlagParser().parse("--bundle=" + bundlePath, "--output=" + outputFilePath, "--aapt2=" + AAPT2_PATH, // Optional values.
"--output-format=" + DIRECTORY), new PrintStream(output), systemEnvironmentProvider, fakeAdbServer);
BuildApksCommand.Builder commandViaBuilder = BuildApksCommand.builder().setBundlePath(bundlePath).setOutputFile(outputFilePath).setOutputFormat(DIRECTORY).setAapt2Command(commandViaFlags.getAapt2Command().get()).setExecutorServiceInternal(commandViaFlags.getExecutorService()).setExecutorServiceCreatedByBundleTool(true).setOutputPrintStream(commandViaFlags.getOutputPrintStream().get());
DebugKeystoreUtils.getDebugSigningConfiguration(systemEnvironmentProvider).ifPresent(commandViaBuilder::setSigningConfiguration);
assertThat(commandViaBuilder.build()).isEqualTo(commandViaFlags);
}
use of com.android.tools.build.bundletool.flags.FlagParser in project bundletool by google.
the class BuildBundleCommandTest method buildingViaFlagsAndBuilderHasSameResult_optionalBundleConfig_inJavaViaFile.
@Test
public void buildingViaFlagsAndBuilderHasSameResult_optionalBundleConfig_inJavaViaFile() throws Exception {
Path modulePath = createSimpleBaseModule();
Path bundleConfigJsonPath = tmpDir.resolve("BundleConfig.pb.json");
Files.write(bundleConfigJsonPath, "{ \"compression\": { \"uncompressedGlob\": [\"foo\"] } }".getBytes(UTF_8));
BuildBundleCommand commandViaBuilder = BuildBundleCommand.builder().setOutputPath(bundlePath).setModulesPaths(ImmutableList.of(modulePath)).setBundleConfig(bundleConfigJsonPath).build();
BuildBundleCommand commandViaFlags = BuildBundleCommand.fromFlags(new FlagParser().parse("--output=" + bundlePath, "--modules=" + modulePath, // Optional values.
"--config=" + bundleConfigJsonPath));
assertThat(commandViaBuilder).isEqualTo(commandViaFlags);
}
use of com.android.tools.build.bundletool.flags.FlagParser in project bundletool by google.
the class BuildBundleCommandTest method buildingViaFlagsAndBuilderHasSameResult.
@Test
public void buildingViaFlagsAndBuilderHasSameResult() throws Exception {
Path baseModulePath = buildSimpleModule("base");
Path featureModulePath = buildSimpleModule("feature");
BuildBundleCommand commandViaBuilder = BuildBundleCommand.builder().setOutputPath(bundlePath).setModulesPaths(ImmutableList.of(baseModulePath, featureModulePath)).build();
BuildBundleCommand commandViaFlags = BuildBundleCommand.fromFlags(new FlagParser().parse("--output=" + bundlePath, "--modules=" + baseModulePath + "," + featureModulePath));
assertThat(commandViaBuilder).isEqualTo(commandViaFlags);
}
use of com.android.tools.build.bundletool.flags.FlagParser in project bundletool by google.
the class BuildBundleCommandTest method buildingViaFlagsAndBuilderHasSameResult_optionalUncompressed.
@Test
public void buildingViaFlagsAndBuilderHasSameResult_optionalUncompressed() throws Exception {
Path baseModulePath = buildSimpleModule("base");
BuildBundleCommand commandViaBuilder = BuildBundleCommand.builder().setOutputPath(bundlePath).setModulesPaths(ImmutableList.of(baseModulePath)).setUncompressedBundle(true).build();
BuildBundleCommand commandViaFlags = BuildBundleCommand.fromFlags(new FlagParser().parse("--output=" + bundlePath, "--modules=" + baseModulePath, "--uncompressed"));
assertThat(commandViaBuilder).isEqualTo(commandViaFlags);
}
use of com.android.tools.build.bundletool.flags.FlagParser in project bundletool by google.
the class BuildBundleCommandTest method buildingViaFlagsAndBuilderHasSameResult_optionalBundleConfig_inJavaViaProto.
@Test
public void buildingViaFlagsAndBuilderHasSameResult_optionalBundleConfig_inJavaViaProto() throws Exception {
Path modulePath = createSimpleBaseModule();
Path bundleConfigJsonPath = tmpDir.resolve("BundleConfig.pb.json");
Files.write(bundleConfigJsonPath, "{ \"compression\": { \"uncompressedGlob\": [\"foo\"] } }".getBytes(UTF_8));
BuildBundleCommand commandViaBuilder = BuildBundleCommand.builder().setOutputPath(bundlePath).setModulesPaths(ImmutableList.of(modulePath)).setBundleConfig(BundleConfig.newBuilder().setCompression(Compression.newBuilder().addUncompressedGlob("foo")).build()).build();
BuildBundleCommand commandViaFlags = BuildBundleCommand.fromFlags(new FlagParser().parse("--output=" + bundlePath, "--modules=" + modulePath, // Optional values.
"--config=" + bundleConfigJsonPath));
assertThat(commandViaBuilder).isEqualTo(commandViaFlags);
}
Aggregations