diff options
author | ajmichael <ajmichael@google.com> | 2017-10-30 11:57:46 -0400 |
---|---|---|
committer | John Cater <jcater@google.com> | 2017-10-31 10:36:54 -0400 |
commit | 5df4759783be1bf6ef54754171e34732aa77d7ba (patch) | |
tree | a7cc2f21f10d6d80676936f818be92475e09b58f /src/main/java/com/google | |
parent | fadeb90a05321195a969ae526ee8cbfea5db6cc6 (diff) |
Make AndroidRuleClasses#hasProguardSpecs less fragile.
Keeps the semantics the same.
RELNOTES: None
PiperOrigin-RevId: 173899927
Diffstat (limited to 'src/main/java/com/google')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/android/AndroidRuleClasses.java | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidRuleClasses.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidRuleClasses.java index d3231d101e..c832717eb5 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidRuleClasses.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidRuleClasses.java @@ -321,9 +321,10 @@ public final class AndroidRuleClasses { public static boolean hasProguardSpecs(AttributeMap rule) { // The below is a hack to support configurable attributes (proguard_specs seems like // too valuable an attribute to make nonconfigurable, and we don't currently - // have the ability to know the configuration when determining implicit outputs). - // An IllegalArgumentException gets triggered if the attribute instance is configurable. - // We assume, heuristically, that means every configurable value is a non-empty list. + // have the ability to know the configuration when determining implicit outputs). So if the + // attribute is configurable, we create the proguard implicit output. At analysis time, we know + // the actual value of proguard_specs, and if it is empty we do not use the proguarded jar for + // dexing. If the user explicitly tries to build the proguard jar, it will fail. // // TODO(bazel-team): find a stronger approach for this. One simple approach is to somehow // receive 'rule' as an AggregatingAttributeMapper instead of a RawAttributeMapper, @@ -332,12 +333,8 @@ public final class AndroidRuleClasses { // to somehow determine implicit outputs after the configuration is known. A third // approach is to refactor the Android rule logic to avoid these dependencies in the // first place. - try { - return !rule.get("proguard_specs", LABEL_LIST).isEmpty(); - } catch (IllegalArgumentException e) { - // We assume at this point the attribute instance is configurable. - return true; - } + return rule.isConfigurable("proguard_specs") + || !rule.get("proguard_specs", LABEL_LIST).isEmpty(); } public static final SafeImplicitOutputsFunction ANDROID_BINARY_IMPLICIT_OUTPUTS = |