aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java6
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/AndroidConfiguration.java16
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/AndroidLibrary.java7
3 files changed, 29 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java
index 1198ee341a..d8d856cd58 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java
@@ -165,6 +165,12 @@ public abstract class AndroidBinary implements RuleConfiguredTargetFactory {
ruleContext.throwWithRuleError("Data binding doesn't work with the \"resources\" attribute. "
+ "Use \"resource_files\" instead.");
}
+ if (ruleContext.attributes().isAttributeValueExplicitlySpecified("resources")
+ && !ruleContext.getFragment(AndroidConfiguration.class).allowResourcesAttr()) {
+ ruleContext.throwWithAttributeError(
+ "resources",
+ "The resources attribute has been removed. Please use resource_files instead.");
+ }
}
private static RuleConfiguredTargetBuilder init(
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidConfiguration.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidConfiguration.java
index 036f606ecd..ccc5b4c0f1 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidConfiguration.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidConfiguration.java
@@ -723,6 +723,16 @@ public class AndroidConfiguration extends BuildConfiguration.Fragment {
)
public boolean allowAndroidResources;
+ @Option(
+ name = "experimental_android_allow_resources_attr",
+ 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 allowResourcesAttr;
+
@Override
public FragmentOptions getHost(boolean fallback) {
Options host = (Options) super.getHost(fallback);
@@ -805,6 +815,7 @@ public class AndroidConfiguration extends BuildConfiguration.Fragment {
private final boolean useParallelDex2Oat;
private final boolean useManifestFromResourceApk;
private final boolean allowAndroidResources;
+ private final boolean allowResourcesAttr;
AndroidConfiguration(Options options) throws InvalidConfigurationException {
@@ -844,6 +855,7 @@ public class AndroidConfiguration extends BuildConfiguration.Fragment {
this.useParallelDex2Oat = options.useParallelDex2Oat;
this.useManifestFromResourceApk = options.useManifestFromResourceApk;
this.allowAndroidResources = options.allowAndroidResources;
+ this.allowResourcesAttr = options.allowResourcesAttr;
if (!dexoptsSupportedInIncrementalDexing.contains("--no-locals")) {
// TODO(bazel-team): Still needed? See DexArchiveAspect
@@ -986,6 +998,10 @@ public class AndroidConfiguration extends BuildConfiguration.Fragment {
return this.allowAndroidResources;
}
+ public boolean allowResourcesAttr() {
+ return this.allowResourcesAttr;
+ }
+
@Override
public void addGlobalMakeVariables(ImmutableMap.Builder<String, String> globalMakeEnvBuilder) {
globalMakeEnvBuilder.put("ANDROID_CPU", cpu);
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidLibrary.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidLibrary.java
index 1709701712..dd91d88e37 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidLibrary.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidLibrary.java
@@ -56,6 +56,13 @@ public abstract class AndroidLibrary implements RuleConfiguredTargetFactory {
ruleContext.throwWithRuleError("Data binding doesn't work with the \"resources\" attribute. "
+ "Use \"resource_files\" instead.");
}
+
+ if (ruleContext.attributes().isAttributeValueExplicitlySpecified("resources")
+ && !ruleContext.getFragment(AndroidConfiguration.class).allowResourcesAttr()) {
+ ruleContext.throwWithAttributeError(
+ "resources",
+ "The resources attribute has been removed. Please use resource_files instead.");
+ }
}
/**