Skip to content

Commit 69c3e09

Browse files
committed
Prepare for release 1.17.2.
1 parent 10fa41c commit 69c3e09

File tree

60 files changed

+2516
-858
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+2516
-858
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ https://developer.android.com/studio/command-line/bundletool
4646

4747
## Releases
4848

49-
Latest release: [1.17.1](https://github.com/google/bundletool/releases)
49+
Latest release: [1.17.2](https://github.com/google/bundletool/releases)

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
release_version = 1.17.1
1+
release_version = 1.17.2

src/main/java/com/android/tools/build/bundletool/BundleToolMain.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import com.android.tools.build.bundletool.commands.CheckTransparencyCommand;
2626
import com.android.tools.build.bundletool.commands.CommandHelp;
2727
import com.android.tools.build.bundletool.commands.DumpCommand;
28+
import com.android.tools.build.bundletool.commands.DumpSdkBundleCommand;
2829
import com.android.tools.build.bundletool.commands.EvaluateDeviceTargetingConfigCommand;
2930
import com.android.tools.build.bundletool.commands.ExtractApksCommand;
3031
import com.android.tools.build.bundletool.commands.GetDeviceSpecCommand;
@@ -47,7 +48,7 @@
4748
*
4849
* <p>Consider running with -Dsun.zip.disableMemoryMapping when dealing with large bundles.
4950
*/
50-
public class BundleToolMain {
51+
public final class BundleToolMain {
5152

5253
public static final String HELP_CMD = "help";
5354

@@ -128,6 +129,9 @@ static void main(String[] args, Runtime runtime) {
128129
case DumpCommand.COMMAND_NAME:
129130
DumpCommand.fromFlags(flags).execute();
130131
break;
132+
case DumpSdkBundleCommand.COMMAND_NAME:
133+
DumpSdkBundleCommand.fromFlags(flags).execute();
134+
break;
131135
case GetSizeCommand.COMMAND_NAME:
132136
GetSizeCommand.fromFlags(flags).execute();
133137
break;
@@ -259,4 +263,6 @@ public static void help(String commandName, Runtime runtime) {
259263

260264
commandHelp.printDetails(System.out);
261265
}
266+
267+
private BundleToolMain() {}
262268
}

src/main/java/com/android/tools/build/bundletool/androidtools/DefaultCommandExecutor.java

+61-21
Original file line numberDiff line numberDiff line change
@@ -20,43 +20,57 @@
2020
import com.android.tools.build.bundletool.model.exceptions.CommandExecutionException;
2121
import com.android.tools.build.bundletool.model.utils.files.BufferedIo;
2222
import com.google.common.collect.ImmutableList;
23-
import com.google.common.io.CharStreams;
23+
import com.google.common.io.LineReader;
2424
import java.io.BufferedReader;
2525
import java.io.IOException;
26+
import java.io.InputStream;
27+
import java.io.PrintStream;
2628
import java.io.UncheckedIOException;
29+
import java.lang.ProcessBuilder.Redirect;
30+
import java.util.ArrayList;
31+
import java.util.List;
2732

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

3136
@Override
3237
public void execute(ImmutableList<String> command, CommandOptions options) {
33-
executeImpl(command, options);
38+
ImmutableList<String> capturedOutput = executeImpl(command, options);
39+
printOutput(capturedOutput, System.out);
3440
}
3541

3642
@Override
3743
public ImmutableList<String> executeAndCapture(
3844
ImmutableList<String> command, CommandOptions options) {
39-
return captureOutput(executeImpl(command, options));
45+
return executeImpl(command, options);
4046
}
4147

42-
private static Process executeImpl(ImmutableList<String> command, CommandOptions options) {
48+
private static ImmutableList<String> executeImpl(
49+
ImmutableList<String> command, CommandOptions options) {
4350
try {
44-
Process process = new ProcessBuilder(command).redirectErrorStream(true).start();
51+
Process process =
52+
new ProcessBuilder(command)
53+
.redirectOutput(Redirect.PIPE)
54+
.redirectErrorStream(true)
55+
.start();
56+
57+
OutputCapturer outputCapturer = OutputCapturer.startCapture(process.getInputStream());
58+
4559
if (!process.waitFor(options.getTimeout().toMillis(), MILLISECONDS)) {
46-
printOutput(process);
60+
printOutput(outputCapturer.getOutput(/* interrupt= */ true), System.err);
4761
throw CommandExecutionException.builder()
4862
.withInternalMessage("Command timed out: %s", command)
4963
.build();
5064
}
5165
if (process.exitValue() != 0) {
52-
printOutput(process);
66+
printOutput(outputCapturer.getOutput(/* interrupt= */ true), System.err);
5367
throw CommandExecutionException.builder()
5468
.withInternalMessage(
5569
"Command '%s' didn't terminate successfully (exit code: %d). Check the logs.",
5670
command, process.exitValue())
5771
.build();
5872
}
59-
return process;
73+
return outputCapturer.getOutput(/* interrupt= */ false);
6074
} catch (IOException | InterruptedException e) {
6175
throw CommandExecutionException.builder()
6276
.withInternalMessage("Error when executing command: %s", command)
@@ -65,22 +79,48 @@ private static Process executeImpl(ImmutableList<String> command, CommandOptions
6579
}
6680
}
6781

68-
private static ImmutableList<String> captureOutput(Process process) {
69-
try (BufferedReader outputReader = BufferedIo.reader(process.getInputStream())) {
70-
return ImmutableList.copyOf(CharStreams.readLines(outputReader));
71-
} catch (IOException e) {
72-
throw new UncheckedIOException(e);
82+
static class OutputCapturer {
83+
private final Thread thread;
84+
private final List<String> output;
85+
private final InputStream stream;
86+
87+
private OutputCapturer(Thread thread, List<String> output, InputStream stream) {
88+
this.thread = thread;
89+
this.output = output;
90+
this.stream = stream;
7391
}
74-
}
7592

76-
private static void printOutput(Process process) {
77-
try (BufferedReader outputReader = BufferedIo.reader(process.getInputStream())) {
78-
String line;
79-
while ((line = outputReader.readLine()) != null) {
80-
System.err.println(line);
93+
static OutputCapturer startCapture(InputStream stream) {
94+
List<String> output = new ArrayList<>();
95+
Thread thread =
96+
new Thread(
97+
() -> {
98+
try (BufferedReader reader = BufferedIo.reader(stream)) {
99+
LineReader lineReader = new LineReader(reader);
100+
String line;
101+
while ((line = lineReader.readLine()) != null) {
102+
output.add(line);
103+
}
104+
} catch (IOException e) {
105+
throw new UncheckedIOException(e);
106+
}
107+
});
108+
thread.start();
109+
return new OutputCapturer(thread, output, stream);
110+
}
111+
112+
ImmutableList<String> getOutput(boolean interrupt) throws InterruptedException, IOException {
113+
if (interrupt) {
114+
stream.close();
81115
}
82-
} catch (IOException e) {
83-
System.err.println("Error when printing output of command:" + e.getMessage());
116+
thread.join();
117+
return ImmutableList.copyOf(output);
118+
}
119+
}
120+
121+
private static void printOutput(List<String> output, PrintStream stream) {
122+
for (String line : output) {
123+
stream.println(line);
84124
}
85125
}
86126
}

src/main/java/com/android/tools/build/bundletool/commands/BuildApksCommand.java

+1
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,7 @@ public Path execute() {
920920
bundleValidator.validate(appBundle);
921921
ImmutableMap<String, BundleModule> sdkBundleModules =
922922
getValidatedSdkModules(closer, tempDir, appBundle);
923+
bundleValidator.validateBundleWithSdkModules(appBundle, sdkBundleModules);
923924

924925
AppBundlePreprocessorManager appBundlePreprocessorManager =
925926
DaggerAppBundlePreprocessorComponent.builder()

src/main/java/com/android/tools/build/bundletool/commands/BuildApksManager.java

-1
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,6 @@ private ApkGenerationConfiguration.Builder getCommonSplitApkGenerationConfigurat
364364
.getMinSdkForAdditionalVariantWithV3Rotation()
365365
.ifPresent(apkGenerationConfiguration::setMinSdkForAdditionalVariantWithV3Rotation);
366366

367-
368367
return apkGenerationConfiguration;
369368
}
370369

src/main/java/com/android/tools/build/bundletool/commands/BuildSdkApksCommand.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public enum OutputFormat {
9898

9999
abstract Optional<Path> getSdkArchivePath();
100100

101-
abstract Integer getVersionCode();
101+
abstract int getVersionCode();
102102

103103
abstract Path getOutputFile();
104104

@@ -126,7 +126,6 @@ ListeningExecutorService getExecutorService() {
126126

127127
public abstract Optional<Integer> getFirstVariantNumber();
128128

129-
130129
public abstract Optional<Integer> getMinSdkVersion();
131130

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

152151
/** Sets the SDK version code */
153-
public abstract Builder setVersionCode(Integer versionCode);
152+
public abstract Builder setVersionCode(int versionCode);
154153

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

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

0 commit comments

Comments
 (0)