Skip to content

Commit

Permalink
Set databinding to v2, v3.4.0+ args to true, and databinding AndroidX…
Browse files Browse the repository at this point in the history
… to true and remove resulting dead code.

RELNOTES: Set Android Databinding to v2 and Databinging AndroidX to true and remove support for Databinding V1.
PiperOrigin-RevId: 559262918
Change-Id: I82ec413531e28846cbe122f903143f29cd4e2e6f
  • Loading branch information
ahumesky authored and copybara-github committed Aug 22, 2023
1 parent 54f750f commit 6a19449
Show file tree
Hide file tree
Showing 24 changed files with 73 additions and 1,216 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -683,33 +683,33 @@ public static class Options extends FragmentOptions {

@Option(
name = "experimental_android_databinding_v2",
defaultValue = "false",
defaultValue = "true",
documentationCategory = OptionDocumentationCategory.OUTPUT_PARAMETERS,
effectTags = {
OptionEffectTag.AFFECTS_OUTPUTS,
OptionEffectTag.LOADING_AND_ANALYSIS,
OptionEffectTag.LOSES_INCREMENTAL_STATE,
},
metadataTags = OptionMetadataTag.EXPERIMENTAL,
help = "Use android databinding v2")
help = "Use android databinding v2. This flag is a no-op.")
public boolean dataBindingV2;

@Option(
name = "android_databinding_use_v3_4_args",
defaultValue = "false",
defaultValue = "true",
documentationCategory = OptionDocumentationCategory.OUTPUT_PARAMETERS,
effectTags = {
OptionEffectTag.AFFECTS_OUTPUTS,
OptionEffectTag.LOADING_AND_ANALYSIS,
OptionEffectTag.LOSES_INCREMENTAL_STATE,
},
metadataTags = OptionMetadataTag.EXPERIMENTAL,
help = "Use android databinding v2 with 3.4.0 argument")
help = "Use android databinding v2 with 3.4.0 argument. This flag is a no-op.")
public boolean dataBindingUpdatedArgs;

@Option(
name = "android_databinding_use_androidx",
defaultValue = "false",
defaultValue = "true",
documentationCategory = OptionDocumentationCategory.OUTPUT_PARAMETERS,
effectTags = {
OptionEffectTag.AFFECTS_OUTPUTS,
Expand All @@ -719,7 +719,7 @@ public static class Options extends FragmentOptions {
metadataTags = OptionMetadataTag.EXPERIMENTAL,
help =
"Generate AndroidX-compatible data-binding files. "
+ "This is only used with databinding v2.")
+ "This is only used with databinding v2. This flag is a no-op.")
public boolean dataBindingAndroidX;

@Option(
Expand Down Expand Up @@ -1185,9 +1185,6 @@ public FragmentOptions getExec() {
private final boolean fixedResourceNeverlinking;
private final boolean checkForMigrationTag;
private final boolean oneVersionEnforcementUseTransitiveJarsForBinaryUnderTest;
private final boolean dataBindingV2;
private final boolean dataBindingUpdatedArgs;
private final boolean dataBindingAndroidX;
private final boolean persistentAarExtractor;
private final boolean persistentBusyboxTools;
private final boolean persistentMultiplexBusyboxTools;
Expand Down Expand Up @@ -1248,9 +1245,6 @@ public AndroidConfiguration(BuildOptions buildOptions) throws InvalidConfigurati
this.checkForMigrationTag = options.checkForMigrationTag || options.disableNativeAndroidRules;
this.oneVersionEnforcementUseTransitiveJarsForBinaryUnderTest =
options.oneVersionEnforcementUseTransitiveJarsForBinaryUnderTest;
this.dataBindingV2 = options.dataBindingV2;
this.dataBindingUpdatedArgs = options.dataBindingUpdatedArgs;
this.dataBindingAndroidX = options.dataBindingAndroidX;
this.persistentAarExtractor = options.persistentAarExtractor;
this.persistentBusyboxTools = options.persistentBusyboxTools;
this.persistentMultiplexBusyboxTools = options.persistentMultiplexBusyboxTools;
Expand Down Expand Up @@ -1479,21 +1473,6 @@ public boolean getOneVersionEnforcementUseTransitiveJarsForBinaryUnderTest() {
return oneVersionEnforcementUseTransitiveJarsForBinaryUnderTest;
}

@Override
public boolean useDataBindingV2() {
return dataBindingV2;
}

@Override
public boolean useDataBindingUpdatedArgs() {
return dataBindingUpdatedArgs;
}

@Override
public boolean useDataBindingAndroidX() {
return dataBindingAndroidX;
}

@Override
public boolean persistentAarExtractor() {
return persistentAarExtractor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ public static AndroidResources create(
AndroidDataContext dataContext,
AndroidResources androidResources,
String appId,
Artifact dataBindingLayoutInfoOut,
boolean useDataBindingAndroidX) {
Artifact dataBindingLayoutInfoOut) {

ImmutableList.Builder<Artifact> databindingProcessedResourcesBuilder = ImmutableList.builder();
for (Artifact resource : androidResources.getResources()) {
Expand Down Expand Up @@ -91,7 +90,7 @@ public static AndroidResources create(

builder.addOutput("--dataBindingInfoOut", dataBindingLayoutInfoOut);
builder.addFlag("--appId", appId);
builder.maybeAddFlag("--useDataBindingAndroidX", useDataBindingAndroidX);
builder.addFlag("--useDataBindingAndroidX");

builder.buildAndRegister("Processing data binding", "ProcessDatabinding");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ public class AndroidDataContext implements AndroidDataContextApi {
private final boolean throwOnProguardApplyDictionary;
private final boolean throwOnProguardApplyMapping;
private final boolean throwOnResourceConflict;
private final boolean useDataBindingV2;
private final boolean useDataBindingAndroidX;
private final ImmutableMap<String, String> executionInfo;

public static AndroidDataContext forNative(RuleContext ruleContext) {
Expand All @@ -98,8 +96,6 @@ public static AndroidDataContext makeContext(RuleContext ruleContext) {
!hasExemption(ruleContext, "allow_proguard_apply_dictionary", true),
!hasExemption(ruleContext, "allow_proguard_apply_mapping", true),
!hasExemption(ruleContext, "allow_resource_conflicts", true),
androidConfig.useDataBindingV2(),
androidConfig.useDataBindingAndroidX(),
executionInfo);
}

Expand All @@ -122,8 +118,6 @@ protected AndroidDataContext(
boolean throwOnProguardApplyDictionary,
boolean throwOnProguardApplyMapping,
boolean throwOnResourceConflict,
boolean useDataBindingV2,
boolean useDataBindingAndroidX,
ImmutableMap<String, String> executionInfo) {
this.persistentBusyboxToolsEnabled = persistentBusyboxToolsEnabled;
this.persistentMultiplexBusyboxToolsEnabled = persistentMultiplexBusyboxToolsEnabled;
Expand All @@ -136,8 +130,6 @@ protected AndroidDataContext(
this.throwOnProguardApplyDictionary = throwOnProguardApplyDictionary;
this.throwOnProguardApplyMapping = throwOnProguardApplyMapping;
this.throwOnResourceConflict = throwOnResourceConflict;
this.useDataBindingV2 = useDataBindingV2;
this.useDataBindingAndroidX = useDataBindingAndroidX;
this.executionInfo = executionInfo;
}

Expand Down Expand Up @@ -250,14 +242,6 @@ public boolean throwOnResourceConflict() {
return throwOnResourceConflict;
}

public boolean useDataBindingV2() {
return useDataBindingV2;
}

public boolean useDataBindingAndroidX() {
return useDataBindingAndroidX;
}

public boolean annotateRFieldsFromTransitiveDeps() {
return ruleContext.getFeatures().contains(ANNOTATE_R_FIELDS_FROM_TRANSITIVE_DEPS);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private void build(AndroidDataContext dataContext) {
.addAapt()
.addInput("--resources", resourceDirectories, resourceArtifacts)
.addOutput("--output", compiledSymbols)
.maybeAddFlag("--useDataBindingAndroidX", dataContext.useDataBindingAndroidX());
.addFlag("--useDataBindingAndroidX");

if (dataBindingInfoZip != null) {
compiledBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,7 @@ public ProcessedAndroidData build(
dataContext, primaryResources, processedManifest.getPackage());

createAapt2ApkAction(
dataContext,
databindingProcessedResources,
primaryAssets,
primaryManifest,
dataBindingContext.usesAndroidX());
dataContext, databindingProcessedResources, primaryAssets, primaryManifest);

// Wrap the parsed resources
ParsedAndroidResources parsedResources =
Expand Down Expand Up @@ -303,8 +299,7 @@ private void createAapt2ApkAction(
AndroidDataContext dataContext,
AndroidResources primaryResources,
AndroidAssets primaryAssets,
StampedAndroidManifest primaryManifest,
boolean useDataBindingAndroidX) {
StampedAndroidManifest primaryManifest) {
BusyBoxActionBuilder builder =
BusyBoxActionBuilder.create(dataContext, "AAPT2_PACKAGE").addAapt();

Expand Down Expand Up @@ -344,7 +339,6 @@ private void createAapt2ApkAction(
primaryResources,
primaryAssets,
primaryManifest,
useDataBindingAndroidX,
builder)
.buildAndRegister("Processing Android resources", "AndroidAapt2");
}
Expand All @@ -354,7 +348,6 @@ private BusyBoxActionBuilder configureCommonFlags(
AndroidResources primaryResources,
AndroidAssets primaryAssets,
StampedAndroidManifest primaryManifest,
boolean useDataBindingAndroidX,
BusyBoxActionBuilder builder) {

return builder
Expand Down Expand Up @@ -388,7 +381,7 @@ private BusyBoxActionBuilder configureCommonFlags(
// and because its resource filtering is somewhat stricter for locales, and resource
// processing needs access to densities to add them to the manifest.
.maybeAddFlag("--resourceConfigs", resourceFilterFactory.getConfigurationFilterString())
.maybeAddFlag("--useDataBindingAndroidX", useDataBindingAndroidX)
.addFlag("--useDataBindingAndroidX")
.maybeAddFlag("--densities", resourceFilterFactory.getDensityString())
.maybeAddVectoredFlag("--uncompressedExtensions", uncompressedExtensions)
.maybeAddFlag("--useAaptCruncher=no", !crunchPng)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ public static MergedAndroidResources mergeFrom(
.setOmitTransitiveDependenciesFromAndroidRClasses(
dataContext.omitTransitiveResourcesFromAndroidRClasses());

parsed.asDataBindingContext().supplyLayoutInfo(builder::setDataBindingInfoZip);

if (dataContext.getAndroidConfig().useRTxtFromMergedResources()) {
builder.setAapt2RTxtOut(
dataContext.createOutputArtifact(AndroidRuleClasses.ANDROID_RESOURCES_AAPT2_R_TXT));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ public static ParsedAndroidResources parseFrom(
throws InterruptedException {
AndroidResourceParsingActionBuilder builder = new AndroidResourceParsingActionBuilder();

// TODO(b/120093531): This is only used in Databinding v1.
dataBindingContext.supplyLayoutInfo(builder::setDataBindingInfoZip);
// In databinding v2, this strips out the databinding and generates the layout info file.
AndroidResources databindingProcessedResources =
dataBindingContext.processResources(dataContext, resources, manifest.getPackage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ public static ProcessedAndroidData processBinaryDataFrom(
AndroidBinary.createMainDexProguardSpec(
dataContext.getLabel(), dataContext.getActionConstructionContext()))
.conditionalKeepRules(conditionalKeepRules);
dataBindingContext.supplyLayoutInfo(builder::setDataBindingInfoZip);
return buildActionForBinary(
dataContext,
dataBindingContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public Artifact build(AndroidDataContext dataContext) {
.addOutput("--shrunkResources", shrunkResourcesOut)
.maybeAddOutput("--resourcesConfigOutput", resourceOptimizationConfigOut)
.addOutput("--log", logOut)
.maybeAddFlag("--useDataBindingAndroidX", dataContext.useDataBindingAndroidX())
.addFlag("--useDataBindingAndroidX")
.buildAndRegister("Shrinking resources", "ResourceShrinker");

return resourceApkOut;
Expand Down
Loading

0 comments on commit 6a19449

Please sign in to comment.