Add flag to fail when android_resources targets are encountered
As part of the migration away from android_resources, add a flag that causes
failures if android_resources is encountered. This makes it easier to test that
all android_resources targets have been removed without actually breaking any
builds.
RELNOTES: none
@@ -697,6 +697,16 @@ public class AndroidConfiguration extends BuildConfiguration.Fragment {
)
public boolean useManifestFromResourceApk;
+ @Option(
+ name = "experimental_android_allow_android_resources",
+ defaultValue = "true",
+ documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
+ effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS},
+ help = "For use in testing before migrating away from android_resources. If false, will"
+ + " fail when android_resources rules are encountered"
+ )
+ public boolean allowAndroidResources;
+
@Override
public FragmentOptions getHost(boolean fallback) {
Options host = (Options) super.getHost(fallback);
@@ -776,6 +786,7 @@ public class AndroidConfiguration extends BuildConfiguration.Fragment {
private final boolean throwOnResourceConflict;
private final boolean useParallelDex2Oat;
private final boolean useManifestFromResourceApk;
+ private final boolean allowAndroidResources;
AndroidConfiguration(Options options) throws InvalidConfigurationException {
@@ -813,6 +824,7 @@ public class AndroidConfiguration extends BuildConfiguration.Fragment {
this.throwOnResourceConflict = options.throwOnResourceConflict;
this.useParallelDex2Oat = options.useParallelDex2Oat;
this.useManifestFromResourceApk = options.useManifestFromResourceApk;
+ this.allowAndroidResources = options.allowAndroidResources;
if (!dexoptsSupportedInIncrementalDexing.contains("--no-locals")) {
// TODO(bazel-team): Still needed? See DexArchiveAspect
@@ -945,6 +957,10 @@ public class AndroidConfiguration extends BuildConfiguration.Fragment {
return useManifestFromResourceApk;
}
+ public boolean allowAndroidResources() {
+ return this.allowAndroidResources;
+ }
+
@Override
public void addGlobalMakeVariables(ImmutableMap.Builder<String, String> globalMakeEnvBuilder) {
globalMakeEnvBuilder.put("ANDROID_CPU", cpu);
