Search in sources :

Example 71 with FlagParser

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);
}
Also used : PrintStream(java.io.PrintStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) FlagParser(com.android.tools.build.bundletool.flags.FlagParser) Test(org.junit.Test)

Example 72 with FlagParser

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);
}
Also used : Path(java.nio.file.Path) ZipPath(com.android.tools.build.bundletool.model.ZipPath) FlagParser(com.android.tools.build.bundletool.flags.FlagParser) Test(org.junit.Test)

Example 73 with FlagParser

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);
}
Also used : Path(java.nio.file.Path) ZipPath(com.android.tools.build.bundletool.model.ZipPath) FlagParser(com.android.tools.build.bundletool.flags.FlagParser) Test(org.junit.Test)

Example 74 with FlagParser

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);
}
Also used : Path(java.nio.file.Path) ZipPath(com.android.tools.build.bundletool.model.ZipPath) FlagParser(com.android.tools.build.bundletool.flags.FlagParser) Test(org.junit.Test)

Example 75 with FlagParser

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);
}
Also used : Path(java.nio.file.Path) ZipPath(com.android.tools.build.bundletool.model.ZipPath) FlagParser(com.android.tools.build.bundletool.flags.FlagParser) Test(org.junit.Test)

Aggregations

FlagParser (com.android.tools.build.bundletool.flags.FlagParser)138 Test (org.junit.Test)137 Path (java.nio.file.Path)63 ZipPath (com.android.tools.build.bundletool.model.ZipPath)55 ByteArrayOutputStream (java.io.ByteArrayOutputStream)29 PrintStream (java.io.PrintStream)29 BuildApksResult (com.android.bundle.Commands.BuildApksResult)22 InvalidCommandException (com.android.tools.build.bundletool.model.exceptions.InvalidCommandException)20 DeviceSpec (com.android.bundle.Devices.DeviceSpec)13 ParsedFlags (com.android.tools.build.bundletool.flags.ParsedFlags)12 ApksigSigningConfiguration (com.android.tools.build.bundletool.model.ApksigSigningConfiguration)10 SigningConfiguration (com.android.tools.build.bundletool.model.SigningConfiguration)10 FlagParseException (com.android.tools.build.bundletool.flags.FlagParser.FlagParseException)8 CommandExecutionException (com.android.tools.build.bundletool.model.exceptions.CommandExecutionException)8 InvalidBundleException (com.android.tools.build.bundletool.model.exceptions.InvalidBundleException)8 TestUtils.expectMissingRequiredBuilderPropertyException (com.android.tools.build.bundletool.testing.TestUtils.expectMissingRequiredBuilderPropertyException)8 TestUtils.expectMissingRequiredFlagException (com.android.tools.build.bundletool.testing.TestUtils.expectMissingRequiredFlagException)8 IOException (java.io.IOException)8 JoseException (org.jose4j.lang.JoseException)7 FakeSystemEnvironmentProvider (com.android.tools.build.bundletool.testing.FakeSystemEnvironmentProvider)6