Skip to content

Commit

Permalink
Prepare for release 1.16.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
gethughed committed Apr 19, 2024
1 parent 0b00e4a commit 9a4a1c9
Show file tree
Hide file tree
Showing 99 changed files with 1,190 additions and 249 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.15.6](https://github.com/google/bundletool/releases)
Latest release: [1.16.0](https://github.com/google/bundletool/releases)
26 changes: 13 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,23 @@ configurations {

// The repackaging rules are defined in the "shadowJar" task below.
dependencies {
implementation "com.android.tools:common:30.1.0-alpha07"
implementation "com.android.tools:common:31.3.0-alpha14"
implementation "com.android.tools:r8:3.3.28"
implementation "com.android.tools.build:apksig:4.2.0-alpha13"
implementation "com.android.tools.ddms:ddmlib:30.1.0-alpha07"
implementation "com.android.tools.ddms:ddmlib:31.3.0-alpha14"
implementation "com.android:zipflinger:7.1.0-alpha07"

shadow "com.android.tools.build:aapt2-proto:7.3.0-alpha07-8248216"
shadow "com.google.auto.value:auto-value-annotations:1.6.2"
annotationProcessor "com.google.auto.value:auto-value:1.6.2"
shadow "com.google.errorprone:error_prone_annotations:2.3.1"
shadow "com.google.guava:guava:31.1-jre"
shadow "com.google.protobuf:protobuf-java:3.19.2"
shadow "com.google.protobuf:protobuf-java-util:3.19.2"
shadow "com.google.guava:guava:32.0.1-jre"
shadow "com.google.protobuf:protobuf-java:3.22.3"
shadow "com.google.protobuf:protobuf-java-util:3.22.3"
shadow "com.google.dagger:dagger:2.28.3"
annotationProcessor "com.google.dagger:dagger-compiler:2.28.3"
shadow "javax.inject:javax.inject:1"
shadow("org.bitbucket.b_c:jose4j:0.7.0") {
shadow("org.bitbucket.b_c:jose4j:0.9.5") {
exclude group: "org.slf4j", module: "slf4j-api"
}
shadow "org.slf4j:slf4j-api:1.7.30"
Expand All @@ -64,12 +64,12 @@ dependencies {
testImplementation "com.google.auto.value:auto-value-annotations:1.6.2"
testAnnotationProcessor "com.google.auto.value:auto-value:1.6.2"
testImplementation "com.google.errorprone:error_prone_annotations:2.3.1"
testImplementation "com.google.guava:guava:31.1-jre"
testImplementation "com.google.truth.extensions:truth-java8-extension:0.45"
testImplementation "com.google.truth.extensions:truth-proto-extension:0.45"
testImplementation "com.google.guava:guava:33.0.0-jre"
testImplementation "com.google.truth:truth:1.4.0"
testImplementation "com.google.truth.extensions:truth-proto-extension:1.4.0"
testImplementation "com.google.jimfs:jimfs:1.1"
testImplementation "com.google.protobuf:protobuf-java:3.19.2"
testImplementation "com.google.protobuf:protobuf-java-util:3.19.2"
testImplementation "com.google.protobuf:protobuf-java:3.25.2"
testImplementation "com.google.protobuf:protobuf-java-util:3.25.2"
testImplementation "org.mockito:mockito-core:2.18.3"
testImplementation "junit:junit:4.12"
testImplementation "org.bouncycastle:bcprov-jdk15on:1.56"
Expand All @@ -84,7 +84,7 @@ dependencies {
testImplementation("org.smali:dexlib2:2.3.4") {
exclude group: "com.google.guava", module: "guava"
}
testImplementation("org.bitbucket.b_c:jose4j:0.7.0") {
testImplementation("org.bitbucket.b_c:jose4j:0.9.5") {
exclude group: "org.slf4j", module: "slf4j-api"
}
testImplementation "org.slf4j:slf4j-api:1.7.30"
Expand Down Expand Up @@ -128,7 +128,7 @@ test {

protobuf {
protoc {
artifact = "com.google.protobuf:protoc:3.19.2"
artifact = "com.google.protobuf:protoc:3.25.2"
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
release_version = 1.15.6
release_version = 1.16.0
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ public static AndroidManifest updateArchivedIconsAndTheme(
return archivedManifestEditor.save();
}


private static Activity createReactivateActivity(
IntentFilter intentFilter, Optional<Integer> icon, Optional<Integer> roundIcon) {
return getCommonActivityBuilder()
Expand Down Expand Up @@ -264,6 +263,5 @@ private static void addTvSupportIfRequired(
editor.addUsesFeatureElement(TOUCHSCREEN_FEATURE_NAME, /* isRequired= */ false);
}


private ArchivedAndroidManifestUtils() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import com.android.apksig.util.DataSource;
import com.android.apksig.util.DataSources;
import com.android.bundle.Devices.DeviceSpec;
import com.android.bundle.FeatureModulesConfigProto.FeatureModulesCustomConfig;
import com.android.bundle.RuntimeEnabledSdkConfigProto.LocalDeploymentRuntimeEnabledSdkConfig;
import com.android.bundle.RuntimeEnabledSdkConfigProto.RuntimeEnabledSdk;
import com.android.tools.build.bundletool.androidtools.Aapt2Command;
Expand Down Expand Up @@ -313,6 +314,10 @@ ListeningExecutorService getExecutorService() {

public abstract boolean getEnableBaseModuleMinSdkAsDefaultTargeting();

public abstract Optional<FeatureModulesCustomConfig> getFeatureModulesCustomConfig();

public abstract Optional<Integer> getMinModulesToEnableFeatureModulesConfig();

public static Builder builder() {
return new AutoValue_BuildApksCommand.Builder()
.setOverwriteOutput(false)
Expand Down Expand Up @@ -582,6 +587,18 @@ public abstract Builder setLocalDeploymentRuntimeEnabledSdkConfig(
*/
public abstract Builder setEnableBaseModuleMinSdkAsDefaultTargeting(boolean value);

/**
* Custom configurations for feature modules.
*
* <p>Used to disable split apk generation for certain feature modules.
*/
public abstract Builder setFeatureModulesCustomConfig(
Optional<FeatureModulesCustomConfig> featureModulesCustomConfig);

/** Minimum number of modules in a variant to enable feature modules config. */
public abstract Builder setMinModulesToEnableFeatureModulesConfig(
int minModulesToEnableFeatureModulesConfig);

abstract BuildApksCommand autoBuild();

public BuildApksCommand build() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.android.bundle.Config.BundleConfig;
import com.android.bundle.Config.ResourceOptimizations.SparseEncoding;
import com.android.bundle.Config.StandaloneConfig.FeatureModulesMode;
import com.android.bundle.Config.UncompressDexFiles;
import com.android.bundle.Devices.DeviceSpec;
import com.android.tools.build.bundletool.archive.ArchivedApksGenerator;
import com.android.tools.build.bundletool.commands.BuildApksCommand.ApkBuildMode;
Expand Down Expand Up @@ -373,6 +374,19 @@ private void setEnableUncompressedDexOptimization(
builder.setEnableDexCompressionSplitter(false);
return;
}
// If uncompressed dex is specified in the BundleConfig it will be honoured.
if (appBundle.getBundleConfig().getOptimizations().hasUncompressDexFiles()) {
UncompressDexFiles uncompressedDexFiles =
appBundle.getBundleConfig().getOptimizations().getUncompressDexFiles();
builder.setEnableDexCompressionSplitter(uncompressedDexFiles.getEnabled());
builder.setDexCompressionSplitterForTargetSdk(
uncompressedDexFiles.getUncompressedDexTargetSdk());
return;
}
// Otherwise we rely on default for bundletool version used to build this AAB:
// * no uncompressed dex for bundletool < 1.12.0;
// * uncompressed dex for Android S+ for bundletool [1.12.0, 1.16.0);
// * uncompressed dex for Android Q+ for bundletool >= 1.16.0.
builder.setEnableDexCompressionSplitter(apkOptimizations.getUncompressDexFiles());
builder.setDexCompressionSplitterForTargetSdk(apkOptimizations.getUncompressedDexTargetSdk());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import com.android.bundle.Config.BundleConfig;
import com.android.bundle.Devices.DeviceSpec;
import com.android.bundle.FeatureModulesConfigProto.FeatureModulesCustomConfig;
import com.android.bundle.RuntimeEnabledSdkConfigProto.LocalDeploymentRuntimeEnabledSdkConfig;
import com.android.tools.build.bundletool.androidtools.P7ZipCommand;
import com.android.tools.build.bundletool.commands.BuildApksCommand.ApkBuildMode;
Expand Down Expand Up @@ -181,6 +182,20 @@ static boolean provideRemoveTvIconCloud(BuildApksCommand command) {
return removeTvIconCloud;
}

@CommandScoped
@Provides
static Optional<FeatureModulesCustomConfig> provideFeatureModulesCustomConfig(
BuildApksCommand command) {
return command.getFeatureModulesCustomConfig();
}

@CommandScoped
@MinModulesToEnableFeatureModulesConfig
@Provides
static Optional<Integer> provideMinModulesToEnableFeatureModulesConfig(BuildApksCommand command) {
return command.getMinModulesToEnableFeatureModulesConfig();
}

/**
* Qualifying annotation of an {@code Optional<Integer>} for the first variant number to use when
* numbering the generated variants.
Expand Down Expand Up @@ -212,5 +227,13 @@ static boolean provideRemoveTvIconCloud(BuildApksCommand command) {
@Retention(RUNTIME)
public @interface RemoveTvIconCloud {}

/**
* Qualifying annotation of an {@code Optional<Integer>} for the minimum number of modules in a
* variant to enable feature modules config.
*/
@Qualifier
@Retention(RUNTIME)
public @interface MinModulesToEnableFeatureModulesConfig {}

private BuildApksModule() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
import com.android.tools.build.bundletool.androidtools.Aapt2Command;
import com.android.tools.build.bundletool.androidtools.P7ZipCommand;
import com.android.tools.build.bundletool.commands.BuildApksCommand.ApkBuildMode;
import com.android.tools.build.bundletool.io.ApkSerializer;
import com.android.tools.build.bundletool.io.ModuleSplitSerializer;
import com.android.tools.build.bundletool.io.ApkSerializerModule;
import com.android.tools.build.bundletool.io.TempDirectory;
import com.android.tools.build.bundletool.model.ApkListener;
import com.android.tools.build.bundletool.model.ApkModifier;
Expand All @@ -38,13 +37,12 @@
import com.android.tools.build.bundletool.optimizations.ApkOptimizations;
import com.google.common.collect.ImmutableList;
import com.google.common.util.concurrent.ListeningExecutorService;
import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import java.util.Optional;

/** Dagger module for build-sdk-apks-for-app command. */
@Module
@Module(includes = {ApkSerializerModule.class})
public abstract class BuildSdkApksForAppModule {

@Provides
Expand Down Expand Up @@ -137,7 +135,4 @@ static Bundle provideBundle(BundleModule module, BundleConfig bundleConfig) {
.setPackageNameOptional(module.getAndroidManifest().getPackageName())
.build();
}

@Binds
abstract ApkSerializer apkSerializerHelper(ModuleSplitSerializer apkSerializerHelper);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
import com.android.tools.build.bundletool.androidtools.Aapt2Command;
import com.android.tools.build.bundletool.androidtools.P7ZipCommand;
import com.android.tools.build.bundletool.commands.BuildApksCommand.ApkBuildMode;
import com.android.tools.build.bundletool.io.ApkSerializer;
import com.android.tools.build.bundletool.io.ModuleSplitSerializer;
import com.android.tools.build.bundletool.io.ApkSerializerModule;
import com.android.tools.build.bundletool.io.TempDirectory;
import com.android.tools.build.bundletool.model.ApkListener;
import com.android.tools.build.bundletool.model.ApkModifier;
Expand All @@ -42,7 +41,7 @@
import java.util.Optional;

/** Dagger module for the build-sdk-apks command. */
@Module
@Module(includes = {ApkSerializerModule.class})
public abstract class BuildSdkApksModule {

@Provides
Expand Down Expand Up @@ -128,7 +127,4 @@ static Optional<Integer> provideFirstVariantNumber(BuildSdkApksCommand command)
static boolean provideVerbose(BuildSdkApksCommand command) {
return command.getVerbose();
}

@Binds
abstract ApkSerializer apkSerializerHelper(ModuleSplitSerializer apkSerializerHelper);
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.android.bundle.Commands.ExtractApksResult;
import com.android.bundle.Commands.ExtractedApk;
import com.android.bundle.Commands.LocalTestingInfoForMetadata;
import com.android.bundle.Commands.Variant;
import com.android.bundle.Config.SplitDimension.Value;
import com.android.bundle.Devices.DeviceSpec;
import com.android.tools.build.bundletool.commands.CommandHelp.CommandDescription;
Expand All @@ -52,6 +53,7 @@
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import com.google.common.io.ByteStreams;
import com.google.protobuf.Int32Value;
import com.google.protobuf.StringValue;
Expand Down Expand Up @@ -203,9 +205,9 @@ ImmutableList<Path> execute(PrintStream output) {
validateInput();

BuildApksResult toc = ResultUtils.readTableOfContents(getApksArchivePath());
Optional<ImmutableSet<String>> requestedModuleNames =
getModules().map(modules -> resolveRequestedModules(modules, toc));
DeviceSpec deviceSpec = applyDefaultsToDeviceSpec(getDeviceSpec(), toc);
Optional<ImmutableSet<String>> requestedModuleNames =
getModules().map(modules -> resolveRequestedModules(modules, toc, deviceSpec));

ApkMatcher apkMatcher =
new ApkMatcher(
Expand Down Expand Up @@ -233,10 +235,10 @@ ImmutableList<Path> execute(PrintStream output) {
}

static ImmutableSet<String> resolveRequestedModules(
ImmutableSet<String> requestedModules, BuildApksResult toc) {
ImmutableSet<String> requestedModules, BuildApksResult toc, DeviceSpec deviceSpec) {
return requestedModules.contains(ALL_MODULES_SHORTCUT)
? Stream.concat(
toc.getVariantList().stream()
getVariantsMatchingSdkRuntimeTargeting(toc, deviceSpec).stream()
.flatMap(variant -> variant.getApkSetList().stream())
.map(apkSet -> apkSet.getModuleMetadata().getName()),
toc.getAssetSliceSetList().stream()
Expand All @@ -246,6 +248,20 @@ static ImmutableSet<String> resolveRequestedModules(
: requestedModules;
}

private static ImmutableSet<Variant> getVariantsMatchingSdkRuntimeTargeting(
BuildApksResult toc, DeviceSpec deviceSpec) {
ImmutableSet<Variant> sdkRuntimeVariants =
toc.getVariantList().stream()
.filter(
variant -> variant.getTargeting().getSdkRuntimeTargeting().getRequiresSdkRuntime())
.collect(toImmutableSet());
if (deviceSpec.getSdkRuntime().getSupported() && !sdkRuntimeVariants.isEmpty()) {
return sdkRuntimeVariants;
}
return Sets.difference(ImmutableSet.copyOf(toc.getVariantList()), sdkRuntimeVariants)
.immutableCopy();
}

private void validateInput() {
if (getModules().isPresent() && getModules().get().isEmpty()) {
throw InvalidCommandException.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ private ImmutableList<Path> getApksToInstall(
.map(AssetModuleMetadata::getName)
.collect(toImmutableSet());
getModules()
.map(modules -> ExtractApksCommand.resolveRequestedModules(modules, toc))
.map(modules -> ExtractApksCommand.resolveRequestedModules(modules, toc, deviceSpec))
.map(modules -> Sets.difference(modules, dynamicAssetModules).immutableCopy())
.ifPresent(extractApksCommand::setModules);
return extractApksCommand.build().execute();
Expand Down Expand Up @@ -323,7 +323,7 @@ private ImmutableList<Path> getApksToPushToStorage(
.collect(toImmutableSet());
ImmutableSet<String> allModules =
ExtractApksCommand.resolveRequestedModules(
ImmutableSet.of(ExtractApksCommand.ALL_MODULES_SHORTCUT), toc);
ImmutableSet.of(ExtractApksCommand.ALL_MODULES_SHORTCUT), toc, deviceSpec);

// We exclude install-time asset modules from the list of requested modules and also force
// the extract-apk layer to skip them explicitly.
Expand Down
Loading

0 comments on commit 9a4a1c9

Please sign in to comment.