Skip to content

Commit

Permalink
Prepare for release 0.9.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
plecesne committed Mar 11, 2019
1 parent fe11298 commit 434f6e5
Show file tree
Hide file tree
Showing 135 changed files with 7,087 additions and 1,402 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -24,4 +24,4 @@ Read more about the App Bundle format and Bundletool's usage at

## Releases

Latest release: [0.8.0](https://github.com/google/bundletool/releases)
Latest release: [0.9.0](https://github.com/google/bundletool/releases)
24 changes: 14 additions & 10 deletions build.gradle
Expand Up @@ -33,26 +33,26 @@ configurations {
// The repackaging rules are defined in the "shadowJar" task below.
dependencies {
compile "com.android.tools:r8:1.0.37"
compile "com.android.tools.build:apkzlib:3.2.0"
compile "com.android.tools.build:apkzlib:3.4.0-beta01"
compile "com.android.tools.ddms:ddmlib:26.2.0"

shadow "com.android.tools.build:aapt2-proto:0.3.1"
shadow "com.android.tools.build:aapt2-proto:0.4.0"
shadow "com.google.auto.value:auto-value:1.5.2"
annotationProcessor "com.google.auto.value:auto-value:1.5.2"
shadow "com.google.errorprone:error_prone_annotations:2.2.0"
shadow "com.google.guava:guava:26.0-jre"
shadow "com.google.errorprone:error_prone_annotations:2.3.1"
shadow "com.google.guava:guava:27.0.1-jre"
shadow "com.google.protobuf:protobuf-java:3.4.0"
shadow "com.google.protobuf:protobuf-java-util:3.4.0"

compileWindows "com.android.tools.build:aapt2:3.2.0-4818971:windows"
compileMacOs "com.android.tools.build:aapt2:3.2.0-4818971:osx"
compileLinux "com.android.tools.build:aapt2:3.2.0-4818971:linux"
compileWindows "com.android.tools.build:aapt2:3.5.0-alpha03-5252756:windows"
compileMacOs "com.android.tools.build:aapt2:3.5.0-alpha03-5252756:osx"
compileLinux "com.android.tools.build:aapt2:3.5.0-alpha03-5252756:linux"

testCompile "com.android.tools.build:aapt2-proto:0.3.1"
testCompile "com.android.tools.build:aapt2-proto:0.4.0"
testCompile "com.google.auto.value:auto-value-annotations:1.5.2"
testAnnotationProcessor "com.google.auto.value:auto-value:1.5.2"
testCompile "com.google.errorprone:error_prone_annotations:2.2.0"
testCompile "com.google.guava:guava:26.0-jre"
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.jimfs:jimfs:1.1"
Expand All @@ -68,6 +68,10 @@ dependencies {

def osName = System.getProperty("os.name").toLowerCase()

// Use utf-8 instead of the platform default encoding.
compileJava.options.encoding = "UTF-8"
compileTestJava.options.encoding = "UTF-8"

test {
if (osName.contains("linux")) {
environment "AAPT2_PATH", "build/resources/main/linux/aapt2"
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
@@ -1 +1 @@
release_version = 0.8.0
release_version = 0.9.0
Expand Up @@ -29,7 +29,7 @@
import com.android.tools.build.bundletool.device.DeviceSpecParser;
import com.android.tools.build.bundletool.flags.Flag;
import com.android.tools.build.bundletool.flags.ParsedFlags;
import com.android.tools.build.bundletool.io.TempFiles;
import com.android.tools.build.bundletool.io.TempDirectory;
import com.android.tools.build.bundletool.model.Aapt2Command;
import com.android.tools.build.bundletool.model.ApkListener;
import com.android.tools.build.bundletool.model.ApkModifier;
Expand All @@ -45,6 +45,7 @@
import com.android.tools.build.bundletool.splitters.NativeLibrariesCompressionSplitter;
import com.google.auto.value.AutoValue;
import com.google.common.base.Ascii;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableSet;
import com.google.common.io.MoreFiles;
import com.google.common.util.concurrent.ListeningExecutorService;
Expand Down Expand Up @@ -77,7 +78,15 @@ 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;

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

public boolean isAnySystemMode() {
return equals(SYSTEM) || equals(SYSTEM_COMPRESSED);
}
}

private static final Flag<Path> BUNDLE_LOCATION_FLAG = Flag.path("bundle");
Expand All @@ -88,7 +97,6 @@ public enum ApkBuildMode {
private static final Flag<Path> AAPT2_PATH_FLAG = Flag.path("aapt2");
private static final Flag<Integer> MAX_THREADS_FLAG = Flag.positiveInteger("max-threads");
private static final Flag<ApkBuildMode> MODE_FLAG = Flag.enumFlag("mode", ApkBuildMode.class);
private static final Flag<Boolean> GENERATE_UNIVERSAL_APK_FLAG = Flag.booleanFlag("universal");

private static final Flag<Path> ADB_PATH_FLAG = Flag.path("adb");
private static final Flag<Boolean> CONNECTED_DEVICE_FLAG = Flag.booleanFlag("connected-device");
Expand Down Expand Up @@ -296,22 +304,45 @@ public BuildApksCommand build() {
throw new ValidationException(
String.format(
"Optimization dimension can be only set when running with '%s' mode flag.",
Ascii.toLowerCase(DEFAULT.name())));
DEFAULT.getLowerCaseName()));
}

if (command.getGenerateOnlyForConnectedDevice()
&& !command.getApkBuildMode().equals(DEFAULT)) {
throw new ValidationException(
String.format(
"Optimizing for connected device only possible when running with '%s' mode flag.",
Ascii.toLowerCase(DEFAULT.name())));
DEFAULT.getLowerCaseName()));
}

if (command.getDeviceSpec().isPresent() && command.getApkBuildMode().equals(UNIVERSAL)) {
throw new ValidationException(
String.format(
"Optimizing for device spec not possible when running with '%s' mode flag.",
Ascii.toLowerCase(UNIVERSAL.name())));
if (command.getDeviceSpec().isPresent()) {
switch (command.getApkBuildMode()) {
case UNIVERSAL:
throw new ValidationException(
String.format(
"Optimizing for device spec not possible when running with '%s' mode flag.",
UNIVERSAL.getLowerCaseName()));
case SYSTEM:
case SYSTEM_COMPRESSED:
DeviceSpec deviceSpec = command.getDeviceSpec().get();
if (deviceSpec.getScreenDensity() == 0 || deviceSpec.getSupportedAbisList().isEmpty()) {
throw new ValidationException(
String.format(
"Device spec must have screen density and ABIs set when running with "
+ "'%s' or '%s' mode flag. ",
SYSTEM.getLowerCaseName(), SYSTEM_COMPRESSED.getLowerCaseName()));
}
break;
case DEFAULT:
}
} else {
if (command.getApkBuildMode().isAnySystemMode()) {
throw ValidationException.builder()
.withMessage(
"Device spec must always be set when running with '%s' or '%s' mode flag.",
SYSTEM.getLowerCaseName(), SYSTEM_COMPRESSED.getLowerCaseName())
.build();
}
}

if (command.getGenerateOnlyForConnectedDevice() && command.getDeviceSpec().isPresent()) {
Expand Down Expand Up @@ -362,14 +393,6 @@ static BuildApksCommand fromFlags(
aapt2Path ->
buildApksCommand.setAapt2Command(Aapt2Command.createFromExecutablePath(aapt2Path)));

if (GENERATE_UNIVERSAL_APK_FLAG.getValue(flags).orElse(false)) {
out.printf(
"WARNING: The '%s' flag is now replaced with --mode=universal and is going to be removed "
+ "in the next BundleTool version.%n",
GENERATE_UNIVERSAL_APK_FLAG.getName());
buildApksCommand.setApkBuildMode(UNIVERSAL);
}

MODE_FLAG.getValue(flags).ifPresent(buildApksCommand::setApkBuildMode);
MAX_THREADS_FLAG
.getValue(flags)
Expand Down Expand Up @@ -440,17 +463,28 @@ static BuildApksCommand fromFlags(
buildApksCommand.setAdbPath(adbPath).setAdbServer(adbServer);
}

ApkBuildMode apkBuildMode = MODE_FLAG.getValue(flags).orElse(DEFAULT);
boolean supportsPartialDeviceSpecs = apkBuildMode.isAnySystemMode();

Function<Path, DeviceSpec> deviceSpecParser =
supportsPartialDeviceSpecs
? DeviceSpecParser::parsePartialDeviceSpec
: DeviceSpecParser::parseDeviceSpec;

DEVICE_SPEC_FLAG
.getValue(flags)
.ifPresent(path -> buildApksCommand.setDeviceSpec(DeviceSpecParser.parseDeviceSpec(path)));
.map(deviceSpecParser)
.ifPresent(buildApksCommand::setDeviceSpec);

flags.checkNoUnknownFlags();

return buildApksCommand.build();
}

public Path execute() {
return TempFiles.withTempDirectoryReturning(new BuildApksManager(this)::execute);
try (TempDirectory tempDirectory = new TempDirectory()) {
return new BuildApksManager(this).execute(tempDirectory.getPath());
}
}

/**
Expand Down Expand Up @@ -513,10 +547,10 @@ public static CommandHelp help() {
+ "manifest) for the system image.",
BuildApksCommand.COMMAND_NAME,
joinFlagOptions(ApkBuildMode.values()),
Ascii.toLowerCase(DEFAULT.name()),
Ascii.toLowerCase(UNIVERSAL.name()),
Ascii.toLowerCase(SYSTEM.name()),
Ascii.toLowerCase(SYSTEM_COMPRESSED.name()))
DEFAULT.getLowerCaseName(),
UNIVERSAL.getLowerCaseName(),
SYSTEM.getLowerCaseName(),
SYSTEM_COMPRESSED.getLowerCaseName())
.build())
.addFlag(
FlagDescription.builder()
Expand All @@ -538,7 +572,7 @@ public static CommandHelp help() {
+ "--%s=%s flag.",
joinFlagOptions(OptimizationDimension.values()),
MODE_FLAG.getName(),
Ascii.toLowerCase(DEFAULT.name()))
DEFAULT.getLowerCaseName())
.build())
.addFlag(
FlagDescription.builder()
Expand Down Expand Up @@ -592,7 +626,7 @@ public static CommandHelp help() {
"If set, will generate APK Set optimized for the connected device. The "
+ "generated APK Set will only be installable on that specific class of "
+ "devices. This flag should be only be set with --%s=%s flag.",
MODE_FLAG.getName(), Ascii.toLowerCase(DEFAULT.name()))
MODE_FLAG.getName(), DEFAULT.getLowerCaseName())
.build())
.addFlag(
FlagDescription.builder()
Expand Down Expand Up @@ -626,7 +660,7 @@ public static CommandHelp help() {
+ "This flag should be only be set with --%s=%s flag.",
GetDeviceSpecCommand.COMMAND_NAME,
MODE_FLAG.getName(),
Ascii.toLowerCase(DEFAULT.name()))
DEFAULT.getLowerCaseName())
.build())
.build();
}
Expand Down

0 comments on commit 434f6e5

Please sign in to comment.