diff options
author | 2017-02-17 18:04:24 +0000 | |
---|---|---|
committer | 2017-02-20 09:40:52 +0000 | |
commit | 25365d8be015771e817e14f8dc75070b056adc56 (patch) | |
tree | 33e503865225ef55e91718a4b0691add17fe8ada /third_party/java/aosp_gradle_core | |
parent | 8973201eac47ce14afd6b50e9c4ef3f016251bd2 (diff) |
Make resource shrinking able to handle style resource parent references that start with 'style/' instead of the more strict '@style/'. AAPT will handle either format, so the resource shrinker should as well to prevent build failures that only occur when shrinking.
--
PiperOrigin-RevId: 147849301
MOS_MIGRATED_REVID=147849301
Diffstat (limited to 'third_party/java/aosp_gradle_core')
-rw-r--r-- | third_party/java/aosp_gradle_core/java/com/android/build/gradle/tasks/ResourceUsageAnalyzer.java | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/third_party/java/aosp_gradle_core/java/com/android/build/gradle/tasks/ResourceUsageAnalyzer.java b/third_party/java/aosp_gradle_core/java/com/android/build/gradle/tasks/ResourceUsageAnalyzer.java index fe12f83357..b6e70ffd9d 100644 --- a/third_party/java/aosp_gradle_core/java/com/android/build/gradle/tasks/ResourceUsageAnalyzer.java +++ b/third_party/java/aosp_gradle_core/java/com/android/build/gradle/tasks/ResourceUsageAnalyzer.java @@ -30,6 +30,7 @@ import static com.android.SdkConstants.FD_RES_VALUES; import static com.android.SdkConstants.PREFIX_ANDROID; import static com.android.SdkConstants.PREFIX_RESOURCE_REF; import static com.android.SdkConstants.PREFIX_THEME_REF; +import static com.android.SdkConstants.REFERENCE_STYLE; import static com.android.SdkConstants.STYLE_RESOURCE_PREFIX; import static com.android.SdkConstants.TAG_ITEM; import static com.android.SdkConstants.TAG_RESOURCES; @@ -1356,7 +1357,15 @@ public class ResourceUsageAnalyzer { } else if (!parent.isEmpty()) { String parentStyle = parent; if (!parentStyle.startsWith(STYLE_RESOURCE_PREFIX)) { - parentStyle = STYLE_RESOURCE_PREFIX + parentStyle; + // Fix (see method comment): allow parent references to start with 'style/' + // as well as the more strict '@style/'. + // TODO(apell): Remove handling of 'style/' references when no longer supported + // by AAPT. + if (parentStyle.startsWith(REFERENCE_STYLE)) { + parentStyle = "@" + parentStyle; + } else { + parentStyle = STYLE_RESOURCE_PREFIX + parentStyle; + } } Resource ps = getResourceFromUrl(LintUtils.getFieldName(parentStyle)); if (ps != null && definition != null) { |