Skip to content

Commit

Permalink
Add an allowlist to restrict access to multidex = "off"
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 438478135
  • Loading branch information
cushon authored and copybara-github committed Mar 31, 2022
1 parent 203f2c5 commit ad26161
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import com.google.devtools.build.lib.actions.ParamFileInfo;
import com.google.devtools.build.lib.actions.ParameterFile;
import com.google.devtools.build.lib.actions.ParameterFile.ParameterFileType;
import com.google.devtools.build.lib.analysis.Allowlist;
import com.google.devtools.build.lib.analysis.AnalysisUtils;
import com.google.devtools.build.lib.analysis.ConfiguredTarget;
import com.google.devtools.build.lib.analysis.FileProvider;
Expand Down Expand Up @@ -174,6 +175,12 @@ private static void validateRuleContext(RuleContext ruleContext, AndroidDataCont
ruleContext.throwWithAttributeError("shrink_resources", "This attribute is not supported");
}

if (Allowlist.hasAllowlist(ruleContext, "android_multidex_off_allowlist")
&& !Allowlist.isAvailable(ruleContext, "android_multidex_off_allowlist")
&& AndroidBinary.getMultidexMode(ruleContext) == MultidexMode.OFF) {
ruleContext.attributeError("multidex", "Multidex must be enabled");
}

if (AndroidCommon.getAndroidConfig(ruleContext).desugarJava8Libs()
&& getMultidexMode(ruleContext) == MultidexMode.OFF) {
// Multidex is required so we can include legacy libs as a separate .dex file.
Expand Down

0 comments on commit ad26161

Please sign in to comment.