Skip to content

Commit

Permalink
Prepare for release 1.17.2.
Browse files Browse the repository at this point in the history
  • Loading branch information
w3roberts committed Oct 22, 2024
1 parent 10fa41c commit 69c3e09
Show file tree
Hide file tree
Showing 60 changed files with 2,516 additions and 858 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ https://developer.android.com/studio/command-line/bundletool

## Releases

Latest release: [1.17.1](https://github.com/google/bundletool/releases)
Latest release: [1.17.2](https://github.com/google/bundletool/releases)
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
release_version = 1.17.1
release_version = 1.17.2
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.android.tools.build.bundletool.commands.CheckTransparencyCommand;
import com.android.tools.build.bundletool.commands.CommandHelp;
import com.android.tools.build.bundletool.commands.DumpCommand;
import com.android.tools.build.bundletool.commands.DumpSdkBundleCommand;
import com.android.tools.build.bundletool.commands.EvaluateDeviceTargetingConfigCommand;
import com.android.tools.build.bundletool.commands.ExtractApksCommand;
import com.android.tools.build.bundletool.commands.GetDeviceSpecCommand;
Expand All @@ -47,7 +48,7 @@
*
* <p>Consider running with -Dsun.zip.disableMemoryMapping when dealing with large bundles.
*/
public class BundleToolMain {
public final class BundleToolMain {

public static final String HELP_CMD = "help";

Expand Down Expand Up @@ -128,6 +129,9 @@ static void main(String[] args, Runtime runtime) {
case DumpCommand.COMMAND_NAME:
DumpCommand.fromFlags(flags).execute();
break;
case DumpSdkBundleCommand.COMMAND_NAME:
DumpSdkBundleCommand.fromFlags(flags).execute();
break;
case GetSizeCommand.COMMAND_NAME:
GetSizeCommand.fromFlags(flags).execute();
break;
Expand Down Expand Up @@ -259,4 +263,6 @@ public static void help(String commandName, Runtime runtime) {

commandHelp.printDetails(System.out);
}

private BundleToolMain() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,43 +20,57 @@
import com.android.tools.build.bundletool.model.exceptions.CommandExecutionException;
import com.android.tools.build.bundletool.model.utils.files.BufferedIo;
import com.google.common.collect.ImmutableList;
import com.google.common.io.CharStreams;
import com.google.common.io.LineReader;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.io.UncheckedIOException;
import java.lang.ProcessBuilder.Redirect;
import java.util.ArrayList;
import java.util.List;

/** Helper to execute native commands. */
public final class DefaultCommandExecutor implements CommandExecutor {

@Override
public void execute(ImmutableList<String> command, CommandOptions options) {
executeImpl(command, options);
ImmutableList<String> capturedOutput = executeImpl(command, options);
printOutput(capturedOutput, System.out);
}

@Override
public ImmutableList<String> executeAndCapture(
ImmutableList<String> command, CommandOptions options) {
return captureOutput(executeImpl(command, options));
return executeImpl(command, options);
}

private static Process executeImpl(ImmutableList<String> command, CommandOptions options) {
private static ImmutableList<String> executeImpl(
ImmutableList<String> command, CommandOptions options) {
try {
Process process = new ProcessBuilder(command).redirectErrorStream(true).start();
Process process =
new ProcessBuilder(command)
.redirectOutput(Redirect.PIPE)
.redirectErrorStream(true)
.start();

OutputCapturer outputCapturer = OutputCapturer.startCapture(process.getInputStream());

if (!process.waitFor(options.getTimeout().toMillis(), MILLISECONDS)) {
printOutput(process);
printOutput(outputCapturer.getOutput(/* interrupt= */ true), System.err);
throw CommandExecutionException.builder()
.withInternalMessage("Command timed out: %s", command)
.build();
}
if (process.exitValue() != 0) {
printOutput(process);
printOutput(outputCapturer.getOutput(/* interrupt= */ true), System.err);
throw CommandExecutionException.builder()
.withInternalMessage(
"Command '%s' didn't terminate successfully (exit code: %d). Check the logs.",
command, process.exitValue())
.build();
}
return process;
return outputCapturer.getOutput(/* interrupt= */ false);
} catch (IOException | InterruptedException e) {
throw CommandExecutionException.builder()
.withInternalMessage("Error when executing command: %s", command)
Expand All @@ -65,22 +79,48 @@ private static Process executeImpl(ImmutableList<String> command, CommandOptions
}
}

private static ImmutableList<String> captureOutput(Process process) {
try (BufferedReader outputReader = BufferedIo.reader(process.getInputStream())) {
return ImmutableList.copyOf(CharStreams.readLines(outputReader));
} catch (IOException e) {
throw new UncheckedIOException(e);
static class OutputCapturer {
private final Thread thread;
private final List<String> output;
private final InputStream stream;

private OutputCapturer(Thread thread, List<String> output, InputStream stream) {
this.thread = thread;
this.output = output;
this.stream = stream;
}
}

private static void printOutput(Process process) {
try (BufferedReader outputReader = BufferedIo.reader(process.getInputStream())) {
String line;
while ((line = outputReader.readLine()) != null) {
System.err.println(line);
static OutputCapturer startCapture(InputStream stream) {
List<String> output = new ArrayList<>();
Thread thread =
new Thread(
() -> {
try (BufferedReader reader = BufferedIo.reader(stream)) {
LineReader lineReader = new LineReader(reader);
String line;
while ((line = lineReader.readLine()) != null) {
output.add(line);
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
});
thread.start();
return new OutputCapturer(thread, output, stream);
}

ImmutableList<String> getOutput(boolean interrupt) throws InterruptedException, IOException {
if (interrupt) {
stream.close();
}
} catch (IOException e) {
System.err.println("Error when printing output of command:" + e.getMessage());
thread.join();
return ImmutableList.copyOf(output);
}
}

private static void printOutput(List<String> output, PrintStream stream) {
for (String line : output) {
stream.println(line);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,7 @@ public Path execute() {
bundleValidator.validate(appBundle);
ImmutableMap<String, BundleModule> sdkBundleModules =
getValidatedSdkModules(closer, tempDir, appBundle);
bundleValidator.validateBundleWithSdkModules(appBundle, sdkBundleModules);

AppBundlePreprocessorManager appBundlePreprocessorManager =
DaggerAppBundlePreprocessorComponent.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,6 @@ private ApkGenerationConfiguration.Builder getCommonSplitApkGenerationConfigurat
.getMinSdkForAdditionalVariantWithV3Rotation()
.ifPresent(apkGenerationConfiguration::setMinSdkForAdditionalVariantWithV3Rotation);


return apkGenerationConfiguration;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public enum OutputFormat {

abstract Optional<Path> getSdkArchivePath();

abstract Integer getVersionCode();
abstract int getVersionCode();

abstract Path getOutputFile();

Expand Down Expand Up @@ -126,7 +126,6 @@ ListeningExecutorService getExecutorService() {

public abstract Optional<Integer> getFirstVariantNumber();


public abstract Optional<Integer> getMinSdkVersion();

/** Creates a builder for the {@link BuildSdkApksCommand} with some default settings. */
Expand All @@ -150,7 +149,7 @@ public abstract static class Builder {
public abstract Builder setSdkArchivePath(Path sdkArchivePath);

/** Sets the SDK version code */
public abstract Builder setVersionCode(Integer versionCode);
public abstract Builder setVersionCode(int versionCode);

/**
* Sets path to the output produced by the command. Depends on the output format:
Expand Down Expand Up @@ -234,7 +233,6 @@ public Builder setExecutorService(ListeningExecutorService executorService) {
*/
public abstract Builder setFirstVariantNumber(int firstVariantNumber);


/** Overrides value of android:minSdkVersion attribute in the generated APKs. */
public abstract Builder setMinSdkVersion(int minSdkVersion);

Expand Down
Loading

0 comments on commit 69c3e09

Please sign in to comment.