diff options
author | Googler <noreply@google.com> | 2016-08-19 21:05:19 +0000 |
---|---|---|
committer | Yue Gan <yueg@google.com> | 2016-08-22 08:11:35 +0000 |
commit | 4fe2cca9b69bce3af6a451d6957ee732dd268a43 (patch) | |
tree | 47941f77325dfb4c252de098f92e3120a36f6c52 /src/tools/android/java/com/google/devtools/build/android/xml | |
parent | c0e420d2cae980f744d63ff5b32f5b5e002fce3b (diff) |
Flip on @+id parsing by default
Avoid writing the non-values IdXmlResourceValues
to the merged values.xml file. It's redundant
since the merged resources will include the src
layout / menu, etc. file. E.g., adds 25KB out
of 250KB to some merged values.xml.
It can also change the way R.fields are initialized
(ids from values.xml are numbered before other
sources), that would have changed the numbering in
AndroidIntegratinoTest#testAndroidBinaryResourceShrinking
and in AndroidResourceClassWriterAaptTest.
--
MOS_MIGRATED_REVID=130789333
Diffstat (limited to 'src/tools/android/java/com/google/devtools/build/android/xml')
-rw-r--r-- | src/tools/android/java/com/google/devtools/build/android/xml/IdXmlResourceValue.java | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/tools/android/java/com/google/devtools/build/android/xml/IdXmlResourceValue.java b/src/tools/android/java/com/google/devtools/build/android/xml/IdXmlResourceValue.java index ec870d31b5..5bd74f96ef 100644 --- a/src/tools/android/java/com/google/devtools/build/android/xml/IdXmlResourceValue.java +++ b/src/tools/android/java/com/google/devtools/build/android/xml/IdXmlResourceValue.java @@ -17,6 +17,7 @@ import com.google.common.base.MoreObjects; import com.google.devtools.build.android.AndroidDataWritingVisitor; import com.google.devtools.build.android.AndroidDataWritingVisitor.StartTag; import com.google.devtools.build.android.AndroidResourceClassWriter; +import com.google.devtools.build.android.DataResourceXml; import com.google.devtools.build.android.FullyQualifiedName; import com.google.devtools.build.android.XmlResourceValue; import com.google.devtools.build.android.XmlResourceValues; @@ -65,6 +66,14 @@ public class IdXmlResourceValue implements XmlResourceValue { @Override public void write( FullyQualifiedName key, Path source, AndroidDataWritingVisitor mergedDataWriter) { + if (!DataResourceXml.isInValuesFolder(source)) { + /* Don't write IDs that were never defined in values, into the merged values.xml, to preserve + * the way initializers are assigned in the R class. Depends on + * DataResourceXml#combineSources to accurately determine when a value is ever defined in a + * values file. + */ + return; + } StartTag startTag = mergedDataWriter .define(key) |