Skip to content

Commit

Permalink
Prepare for release 0.10.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
plecesne committed Jun 17, 2019
1 parent 8e3aef8 commit 5ac94cb
Show file tree
Hide file tree
Showing 126 changed files with 3,203 additions and 1,145 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ Bundletool has a few different responsibilities:
Read more about the App Bundle format and Bundletool's usage at
[g.co/androidappbundle](https://g.co/androidappbundle)

Documentation of bundletool commands can be found at:
https://developer.android.com/studio/command-line/bundletool

## Releases

Latest release: [0.9.0](https://github.com/google/bundletool/releases)
Latest release: [0.10.0](https://github.com/google/bundletool/releases)
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ buildscript {
}
}
dependencies {
classpath "com.google.protobuf:protobuf-gradle-plugin:0.8.3"
classpath "com.github.jengelman.gradle.plugins:shadow:2.0.2"
classpath "com.google.protobuf:protobuf-gradle-plugin:0.8.8"
classpath "com.github.jengelman.gradle.plugins:shadow:4.0.4"
}
}

Expand Down Expand Up @@ -53,8 +53,8 @@ dependencies {
testAnnotationProcessor "com.google.auto.value:auto-value:1.5.2"
testCompile "com.google.errorprone:error_prone_annotations:2.3.1"
testCompile "com.google.guava:guava:27.0.1-jre"
testCompile "com.google.truth.extensions:truth-java8-extension:0.42"
testCompile "com.google.truth.extensions:truth-proto-extension:0.42"
testCompile "com.google.truth.extensions:truth-java8-extension:0.45"
testCompile "com.google.truth.extensions:truth-proto-extension:0.45"
testCompile "com.google.jimfs:jimfs:1.1"
testCompile "com.google.protobuf:protobuf-java:3.4.0"
testCompile "com.google.protobuf:protobuf-java-util:3.4.0"
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
release_version = 0.9.0
release_version = 0.10.0
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import static com.android.tools.build.bundletool.commands.BuildApksCommand.ApkBuildMode.SYSTEM;
import static com.android.tools.build.bundletool.commands.BuildApksCommand.ApkBuildMode.SYSTEM_COMPRESSED;
import static com.android.tools.build.bundletool.commands.BuildApksCommand.ApkBuildMode.UNIVERSAL;
import static com.android.tools.build.bundletool.model.utils.SdkToolsLocator.ANDROID_HOME_VARIABLE;
import static com.android.tools.build.bundletool.model.utils.SdkToolsLocator.SYSTEM_PATH_VARIABLE;
import static com.google.common.base.Preconditions.checkArgument;

import com.android.bundle.Devices.DeviceSpec;
Expand Down Expand Up @@ -52,7 +54,6 @@
import com.google.common.util.concurrent.MoreExecutors;
import java.io.PrintStream;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Optional;
import java.util.concurrent.Executors;
Expand All @@ -78,13 +79,19 @@ public enum ApkBuildMode {
* SYSTEM_COMPRESSED mode generates compressed APK and an additional uncompressed stub APK
* (containing only android manifest) for the system image.
*/
SYSTEM_COMPRESSED;
SYSTEM_COMPRESSED,
/** PERSISTENT mode only generates non-instant APKs (i.e. splits and standalone APKs). */
PERSISTENT,
/**
* INSTANT mode only generates instant APKs, assuming at least one module is instant-enabled.
*/
INSTANT;

public String getLowerCaseName() {
public final String getLowerCaseName() {
return Ascii.toLowerCase(name());
}

public boolean isAnySystemMode() {
public final boolean isAnySystemMode() {
return equals(SYSTEM) || equals(SYSTEM_COMPRESSED);
}
}
Expand All @@ -101,7 +108,6 @@ public boolean isAnySystemMode() {
private static final Flag<Path> ADB_PATH_FLAG = Flag.path("adb");
private static final Flag<Boolean> CONNECTED_DEVICE_FLAG = Flag.booleanFlag("connected-device");
private static final Flag<String> DEVICE_ID_FLAG = Flag.string("device-id");
private static final String ANDROID_HOME_VARIABLE = "ANDROID_HOME";
private static final String ANDROID_SERIAL_VARIABLE = "ANDROID_SERIAL";

private static final Flag<Path> DEVICE_SPEC_FLAG = Flag.path("device-spec");
Expand Down Expand Up @@ -208,6 +214,12 @@ public abstract Builder setOptimizationDimensions(
/** Sets the {@link DeviceSpec} for which the only the matching APKs will be generated. */
public abstract Builder setDeviceSpec(DeviceSpec deviceSpec);

/** Sets the {@link DeviceSpec} for which the only the matching APKs will be generated. */
public Builder setDeviceSpec(Path deviceSpecFile) {
// Parse as partial and fully validate later.
return setDeviceSpec(DeviceSpecParser.parsePartialDeviceSpec(deviceSpecFile));
}

/**
* Sets the device serial number. Required if more than one device including emulators is
* connected.
Expand Down Expand Up @@ -316,6 +328,10 @@ public BuildApksCommand build() {
}

if (command.getDeviceSpec().isPresent()) {
boolean supportsPartialDeviceSpecs = command.getApkBuildMode().isAnySystemMode();
DeviceSpecParser.validateDeviceSpec(
command.getDeviceSpec().get(), /* canSkipFields= */ supportsPartialDeviceSpecs);

switch (command.getApkBuildMode()) {
case UNIVERSAL:
throw new ValidationException(
Expand All @@ -334,6 +350,8 @@ public BuildApksCommand build() {
}
break;
case DEFAULT:
case INSTANT:
case PERSISTENT:
}
} else {
if (command.getApkBuildMode().isAnySystemMode()) {
Expand Down Expand Up @@ -451,14 +469,13 @@ static BuildApksCommand fromFlags(
Path adbPath =
adbPathFromFlag.orElseGet(
() ->
systemEnvironmentProvider
.getVariable(ANDROID_HOME_VARIABLE)
.flatMap(path -> new SdkToolsLocator().locateAdb(Paths.get(path)))
new SdkToolsLocator()
.locateAdb(systemEnvironmentProvider)
.orElseThrow(
() ->
new CommandExecutionException(
"Unable to determine the location of ADB. Please set the "
+ "--adb flag or define ANDROID_HOME environment "
"Unable to determine the location of ADB. Please set the --adb "
+ "flag or define ANDROID_HOME or PATH environment "
+ "variable.")));
buildApksCommand.setAdbPath(adbPath).setAdbServer(adbServer);
}
Expand All @@ -482,11 +499,24 @@ static BuildApksCommand fromFlags(
}

public Path execute() {
try (TempDirectory tempDirectory = new TempDirectory()) {
return new BuildApksManager(this).execute(tempDirectory.getPath());
try (TempDirectory tempDir = new TempDirectory()) {
Aapt2Command aapt2 =
getAapt2Command().orElseGet(() -> extractAapt2FromJar(tempDir.getPath()));
return new BuildApksManager(this, aapt2, tempDir.getPath()).execute();
}
}

private static Aapt2Command extractAapt2FromJar(Path tempDir) {
return new SdkToolsLocator()
.extractAapt2(tempDir)
.map(Aapt2Command::createFromExecutablePath)
.orElseThrow(
() ->
new CommandExecutionException(
"Could not extract aapt2: consider updating bundletool to a more recent "
+ "version or providing the path to aapt2 using the flag --aapt2."));
}

/**
* Creates an internal executor service that uses at most the given number of threads.
*
Expand Down Expand Up @@ -635,8 +665,8 @@ public static CommandHelp help() {
.setOptional(true)
.setDescription(
"Path to the adb utility. If absent, an attempt will be made to locate it if "
+ "the %s environment variable is set. Used only if %s flag is set.",
ANDROID_HOME_VARIABLE, CONNECTED_DEVICE_FLAG)
+ "the %s or %s environment variable is set. Used only if %s flag is set.",
ANDROID_HOME_VARIABLE, SYSTEM_PATH_VARIABLE, CONNECTED_DEVICE_FLAG)
.build())
.addFlag(
FlagDescription.builder()
Expand Down
Loading

0 comments on commit 5ac94cb

Please sign in to comment.