aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/tools/android/java/com
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2016-10-25 15:25:09 +0000
committerGravatar John Cater <jcater@google.com>2016-10-25 20:19:14 +0000
commit7260f0a2c69bfe0fec187099fcea2dd16c331729 (patch)
treebab73491fda9476815de0aa1ff80a591041306b9 /src/tools/android/java/com
parentd1f4a167f8080d460dd532eb83b87ab0d0eb4f86 (diff)
Wrap the source Path in a DataSource object.
The DataSource object will then be used to track which values have been overwritten and avoid incorrect merge warnings. -- MOS_MIGRATED_REVID=137159260
Diffstat (limited to 'src/tools/android/java/com')
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/AndroidDataMerger.java28
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/AndroidDataSerializer.java4
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/AndroidDataWriter.java5
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/AndroidDataWritingVisitor.java2
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/DataResourceXml.java45
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/DataSource.java98
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/DataSourceTable.java24
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/DataValue.java5
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/DataValueFile.java15
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/XmlResourceValue.java3
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/xml/ArrayXmlResourceValue.java4
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/xml/AttrXmlResourceValue.java4
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/xml/IdXmlResourceValue.java9
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/xml/PluralXmlResourceValue.java4
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/xml/PublicXmlResourceValue.java4
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/xml/SimpleXmlResourceValue.java4
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/xml/StyleXmlResourceValue.java4
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/xml/StyleableXmlResourceValue.java4
18 files changed, 172 insertions, 94 deletions
diff --git a/src/tools/android/java/com/google/devtools/build/android/AndroidDataMerger.java b/src/tools/android/java/com/google/devtools/build/android/AndroidDataMerger.java
index f622253332..3ee002a98d 100644
--- a/src/tools/android/java/com/google/devtools/build/android/AndroidDataMerger.java
+++ b/src/tools/android/java/com/google/devtools/build/android/AndroidDataMerger.java
@@ -13,6 +13,7 @@
// limitations under the License.
package com.google.devtools.build.android;
+import com.android.ide.common.res2.MergingException;
import com.google.common.base.Joiner;
import com.google.common.base.Stopwatch;
import com.google.common.collect.Iterables;
@@ -21,15 +22,9 @@ import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.devtools.build.android.ParsedAndroidData.Builder;
import com.google.devtools.build.android.ParsedAndroidData.ParsedAndroidDataBuildingPathWalker;
-
-import com.android.ide.common.res2.MergingException;
-
-import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.nio.file.Files;
import java.nio.file.Path;
-import java.nio.file.attribute.BasicFileAttributeView;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@@ -92,7 +87,7 @@ public class AndroidDataMerger {
/** Interface for comparing paths. */
interface SourceChecker {
- boolean checkEquality(Path one, Path two) throws IOException;
+ boolean checkEquality(DataSource one, DataSource two) throws IOException;
}
/** Compares two paths by the contents of the files. */
@@ -103,13 +98,13 @@ public class AndroidDataMerger {
}
@Override
- public boolean checkEquality(Path one, Path two) throws IOException {
+ public boolean checkEquality(DataSource one, DataSource two) throws IOException {
// TODO(corysmith): Is there a filesystem hash we can use?
- if (getFileSize(one) != getFileSize(two)) {
+ if (one.getFileSize() != two.getFileSize()) {
return false;
}
- try (final InputStream oneStream = new BufferedInputStream(Files.newInputStream(one));
- final InputStream twoStream = new BufferedInputStream(Files.newInputStream(two))) {
+ try (final InputStream oneStream = one.newBufferedInputStream();
+ final InputStream twoStream = two.newBufferedInputStream()) {
int bytesRead = 0;
while (true) {
int oneByte = oneStream.read();
@@ -123,11 +118,7 @@ public class AndroidDataMerger {
logger.severe(
String.format(
"Filesystem size of %s (%s) or %s (%s) is inconsistant with bytes read %s.",
- one,
- getFileSize(one),
- two,
- getFileSize(two),
- bytesRead));
+ one, one.getFileSize(), two, two.getFileSize(), bytesRead));
return false;
}
}
@@ -138,9 +129,6 @@ public class AndroidDataMerger {
}
}
- private long getFileSize(Path path) throws IOException {
- return Files.getFileAttributeView(path, BasicFileAttributeView.class).readAttributes().size();
- }
}
static class NoopSourceChecker implements SourceChecker {
@@ -149,7 +137,7 @@ public class AndroidDataMerger {
}
@Override
- public boolean checkEquality(Path one, Path two) {
+ public boolean checkEquality(DataSource one, DataSource two) {
return false;
}
}
diff --git a/src/tools/android/java/com/google/devtools/build/android/AndroidDataSerializer.java b/src/tools/android/java/com/google/devtools/build/android/AndroidDataSerializer.java
index bf6d52dd1c..132133facd 100644
--- a/src/tools/android/java/com/google/devtools/build/android/AndroidDataSerializer.java
+++ b/src/tools/android/java/com/google/devtools/build/android/AndroidDataSerializer.java
@@ -173,7 +173,7 @@ public class AndroidDataSerializer {
// TODO(corysmith): Make this a lazy read of the values.
for (Entry<DataKey, KeyValueConsumer<DataKey, ?>> entry : keys.entrySet()) {
SerializeFormat.DataValue protoValue = SerializeFormat.DataValue.parseDelimitedFrom(in);
- Path source = sourceTable.sourceFromId(protoValue.getSourceId());
+ DataSource source = sourceTable.sourceFromId(protoValue.getSourceId());
if (protoValue.hasXmlValue()) {
// TODO(corysmith): Figure out why the generics are wrong.
// If I use Map<DataKey, KeyValueConsumer<DataKey, ? extends DataValue>>, I can put
@@ -189,7 +189,7 @@ public class AndroidDataSerializer {
@SuppressWarnings("unchecked")
KeyValueConsumer<DataKey, DataValue> value =
(KeyValueConsumer<DataKey, DataValue>) entry.getValue();
- value.consume(entry.getKey(), DataValueFile.from(source));
+ value.consume(entry.getKey(), DataValueFile.of(source));
}
}
}
diff --git a/src/tools/android/java/com/google/devtools/build/android/AndroidDataWriter.java b/src/tools/android/java/com/google/devtools/build/android/AndroidDataWriter.java
index f1db567bb0..92e674cb43 100644
--- a/src/tools/android/java/com/google/devtools/build/android/AndroidDataWriter.java
+++ b/src/tools/android/java/com/google/devtools/build/android/AndroidDataWriter.java
@@ -369,8 +369,9 @@ public class AndroidDataWriter implements AndroidDataWritingVisitor {
}
@Override
- public ValuesResourceDefinition derivedFrom(final Path source) {
- final SegmentMapper mapper = SegmentMapper.create(segments, adopted, segmentsKey, source);
+ public ValuesResourceDefinition derivedFrom(final DataSource source) {
+ final SegmentMapper mapper =
+ SegmentMapper.create(segments, adopted, segmentsKey, source.getPath());
return new StringValuesResourceDefinition(mapper);
}
}
diff --git a/src/tools/android/java/com/google/devtools/build/android/AndroidDataWritingVisitor.java b/src/tools/android/java/com/google/devtools/build/android/AndroidDataWritingVisitor.java
index 1b63d2412a..8d1f547dcf 100644
--- a/src/tools/android/java/com/google/devtools/build/android/AndroidDataWritingVisitor.java
+++ b/src/tools/android/java/com/google/devtools/build/android/AndroidDataWritingVisitor.java
@@ -82,7 +82,7 @@ public interface AndroidDataWritingVisitor extends Flushable {
/** Represents the xml values resource meta data. */
@CheckReturnValue
interface ValueResourceDefinitionMetadata {
- ValuesResourceDefinition derivedFrom(Path source);
+ ValuesResourceDefinition derivedFrom(DataSource source);
}
/** Fluent interface to define the xml value for a {@link FullyQualifiedName}. */
diff --git a/src/tools/android/java/com/google/devtools/build/android/DataResourceXml.java b/src/tools/android/java/com/google/devtools/build/android/DataResourceXml.java
index 38e2f52124..1fbbd8c81a 100644
--- a/src/tools/android/java/com/google/devtools/build/android/DataResourceXml.java
+++ b/src/tools/android/java/com/google/devtools/build/android/DataResourceXml.java
@@ -17,7 +17,6 @@ import static com.android.resources.ResourceType.DECLARE_STYLEABLE;
import static com.android.resources.ResourceType.ID;
import static com.android.resources.ResourceType.PUBLIC;
-import com.android.SdkConstants;
import com.android.resources.ResourceType;
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
@@ -134,7 +133,8 @@ public class DataResourceXml implements DataResource {
}
@SuppressWarnings("deprecation")
- public static DataValue from(SerializeFormat.DataValue protoValue, Path source)
+ // TODO(corysmith): Update proto to use get<>Map
+ public static DataValue from(SerializeFormat.DataValue protoValue, DataSource source)
throws InvalidProtocolBufferException {
DataValueXml xmlValue = protoValue.getXmlValue();
return createWithNamespaces(
@@ -225,32 +225,37 @@ public class DataResourceXml implements DataResource {
return ResourceType.getEnum(start.getName().getLocalPart());
}
- private final Path source;
+ private final DataSource source;
private final XmlResourceValue xml;
private final Namespaces namespaces;
- private DataResourceXml(Path source, XmlResourceValue xmlValue, Namespaces namespaces) {
+ private DataResourceXml(DataSource source, XmlResourceValue xmlValue, Namespaces namespaces) {
this.source = source;
this.xml = xmlValue;
this.namespaces = namespaces;
}
- public static DataResourceXml createWithNoNamespace(Path source, XmlResourceValue xml) {
- return createWithNamespaces(source, xml, ImmutableMap.<String, String>of());
+ public static DataResourceXml createWithNoNamespace(Path sourcePath, XmlResourceValue xml) {
+ return createWithNamespaces(sourcePath, xml, ImmutableMap.<String, String>of());
}
public static DataResourceXml createWithNamespaces(
- Path source, XmlResourceValue xml, ImmutableMap<String, String> prefixToUri) {
- return createWithNamespaces(source, xml, Namespaces.from(prefixToUri));
+ Path sourcePath, XmlResourceValue xml, ImmutableMap<String, String> prefixToUri) {
+ return createWithNamespaces(sourcePath, xml, Namespaces.from(prefixToUri));
}
public static DataResourceXml createWithNamespaces(
- Path source, XmlResourceValue xml, Namespaces namespaces) {
+ DataSource source, XmlResourceValue xml, Namespaces namespaces) {
return new DataResourceXml(source, xml, namespaces);
}
+ public static DataResourceXml createWithNamespaces(
+ Path sourcePath, XmlResourceValue xml, Namespaces namespaces) {
+ return createWithNamespaces(DataSource.of(sourcePath), xml, namespaces);
+ }
+
@Override
- public Path source() {
+ public DataSource source() {
return source;
}
@@ -311,23 +316,7 @@ public class DataResourceXml implements DataResource {
namespaces.union(xmlResource.namespaces));
}
- private Path combineSources(Path otherSource) {
- // TODO(corysmith): Combine the sources so that we know both of the originating files.
- // For now, prefer sources that have explicit definitions (values/ and not layout/), since the
- // values are ultimately written out to a merged values.xml. Sources from layout/menu, etc.
- // can come from "@+id" definitions.
- boolean thisInValuesFolder = isInValuesFolder(source);
- boolean otherInValuesFolder = isInValuesFolder(otherSource);
- if (thisInValuesFolder && !otherInValuesFolder) {
- return source;
- }
- if (!thisInValuesFolder && otherInValuesFolder) {
- return otherSource;
- }
- return source;
- }
-
- public static boolean isInValuesFolder(Path source) {
- return source.getParent().getFileName().toString().startsWith(SdkConstants.FD_RES_VALUES);
+ private DataSource combineSources(DataSource otherSource) {
+ return source.combine(otherSource);
}
}
diff --git a/src/tools/android/java/com/google/devtools/build/android/DataSource.java b/src/tools/android/java/com/google/devtools/build/android/DataSource.java
new file mode 100644
index 0000000000..5c51ea729a
--- /dev/null
+++ b/src/tools/android/java/com/google/devtools/build/android/DataSource.java
@@ -0,0 +1,98 @@
+// Copyright 2016 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.devtools.build.android;
+
+import com.android.SdkConstants;
+import com.google.common.base.Objects;
+import com.google.devtools.build.android.proto.SerializeFormat.ProtoSource;
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.FileSystem;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.attribute.BasicFileAttributeView;
+
+/** Represents where the DataValue was derived from. */
+public class DataSource implements Comparable<DataSource> {
+
+ public static DataSource from(ProtoSource protoSource, FileSystem currentFileSystem) {
+ Path path = currentFileSystem.getPath(protoSource.getFilename());
+ return of(path);
+ }
+
+ public static DataSource of(Path source) {
+ return new DataSource(source);
+ }
+
+ private final Path path;
+
+ private DataSource(Path path) {
+ this.path = path;
+ }
+
+ public Path getPath() {
+ return path;
+ }
+
+ public long getFileSize() throws IOException {
+ return Files.getFileAttributeView(path, BasicFileAttributeView.class).readAttributes().size();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ return Objects.equal(path, ((DataSource) o).path);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(path);
+ }
+
+ @Override
+ public int compareTo(DataSource o) {
+ return path.compareTo(o.path);
+ }
+
+ public InputStream newBufferedInputStream() throws IOException {
+ return new BufferedInputStream(Files.newInputStream(path));
+ }
+
+ /** Selects which DataSource should be considered the authoritative source of a value. */
+ // TODO(corysmith): Combine the sources so that we know both of the originating libraries.
+ // For now, prefer sources that have explicit definitions (values/ and not layout/), since the
+ // values are ultimately written out to a merged values.xml. Sources from layout/menu, etc.
+ // can come from "@+id" definitions.
+ public DataSource combine(DataSource otherSource) {
+ boolean thisInValuesFolder = isInValuesFolder();
+ boolean otherInValuesFolder = otherSource.isInValuesFolder();
+ if (thisInValuesFolder && !otherInValuesFolder) {
+ return this;
+ }
+ if (!thisInValuesFolder && otherInValuesFolder) {
+ return otherSource;
+ }
+ return this;
+ }
+
+ public boolean isInValuesFolder() {
+ return path.getParent().getFileName().toString().startsWith(SdkConstants.FD_RES_VALUES);
+ }
+}
diff --git a/src/tools/android/java/com/google/devtools/build/android/DataSourceTable.java b/src/tools/android/java/com/google/devtools/build/android/DataSourceTable.java
index 4ffff3bcde..0a26fc092a 100644
--- a/src/tools/android/java/com/google/devtools/build/android/DataSourceTable.java
+++ b/src/tools/android/java/com/google/devtools/build/android/DataSourceTable.java
@@ -20,23 +20,23 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.FileSystem;
-import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;
import java.util.NavigableMap;
+
/**
* Tracks mappings from resource source paths (/foo/bar/res/values/colors.xml) to an ID for a more
* compact serialization format.
*/
class DataSourceTable {
- private final Map<Path, Integer> sourceTable = new HashMap<>();
- private Path[] idToSource;
+ private final Map<DataSource, Integer> sourceTable = new HashMap<>();
+ private DataSource[] idToSource;
/**
* Creates a DataSourceTable and serialize to the given outstream. Assigns each resource source
- * path a number to enable {@link #getSourceId(Path)} queries.
+ * path a number to enable {@link #getSourceId(DataSource)} queries.
*
* @param map the final map of resources
* @param outStream stream to serialize the source table
@@ -53,7 +53,7 @@ class DataSourceTable {
}
/** Convert the absolute source path to the source table index */
- public int getSourceId(Path source) {
+ public int getSourceId(DataSource source) {
return sourceTable.get(source);
}
@@ -61,11 +61,14 @@ class DataSourceTable {
throws IOException {
int sourceNumber = 0;
for (Map.Entry<DataKey, DataValue> entry : map.entrySet()) {
- Path source = entry.getValue().source();
+ DataSource source = entry.getValue().source();
if (!sourceTable.containsKey(source)) {
sourceTable.put(source, sourceNumber);
++sourceNumber;
- ProtoSource.newBuilder().setFilename(source.toString()).build().writeDelimitedTo(outStream);
+ ProtoSource.newBuilder()
+ .setFilename(source.getPath().toString())
+ .build()
+ .writeDelimitedTo(outStream);
}
}
}
@@ -84,7 +87,7 @@ class DataSourceTable {
}
/** Convert the source ID to full Path */
- public Path sourceFromId(int sourceId) {
+ public DataSource sourceFromId(int sourceId) {
return idToSource[sourceId];
}
@@ -92,11 +95,10 @@ class DataSourceTable {
throws IOException {
int numberOfSources = header.getSourceCount();
// Read back the sources.
- idToSource = new Path[numberOfSources];
+ idToSource = new DataSource[numberOfSources];
for (int i = 0; i < numberOfSources; i++) {
ProtoSource protoSource = SerializeFormat.ProtoSource.parseDelimitedFrom(in);
- Path source = currentFileSystem.getPath(protoSource.getFilename());
- idToSource[i] = source;
+ idToSource[i] = DataSource.from(protoSource, currentFileSystem);
}
}
}
diff --git a/src/tools/android/java/com/google/devtools/build/android/DataValue.java b/src/tools/android/java/com/google/devtools/build/android/DataValue.java
index e8427a4a34..8876c010d6 100644
--- a/src/tools/android/java/com/google/devtools/build/android/DataValue.java
+++ b/src/tools/android/java/com/google/devtools/build/android/DataValue.java
@@ -15,7 +15,6 @@ package com.google.devtools.build.android;
import java.io.IOException;
import java.io.OutputStream;
-import java.nio.file.Path;
/**
* Represents the value associated with DataKey interface for resource and asset values.
@@ -25,9 +24,9 @@ import java.nio.file.Path;
public interface DataValue {
/**
- * Provides the Path to the file from which the DataValue was derived.
+ * Provides the DataSource, which contains metadata about the original xml it was derived from.
*/
- Path source();
+ DataSource source();
/**
* Serializes to a supplied stream and returns the number of bytes written.
diff --git a/src/tools/android/java/com/google/devtools/build/android/DataValueFile.java b/src/tools/android/java/com/google/devtools/build/android/DataValueFile.java
index b2166f3c16..a54c8ef6da 100644
--- a/src/tools/android/java/com/google/devtools/build/android/DataValueFile.java
+++ b/src/tools/android/java/com/google/devtools/build/android/DataValueFile.java
@@ -29,16 +29,19 @@ import java.util.Objects;
*/
public class DataValueFile implements DataResource, DataAsset {
- private final Path source;
+ private final DataSource source;
- private DataValueFile(Path source) {
+ private DataValueFile(DataSource source) {
this.source = source;
}
public static DataValueFile of(Path source) {
- return new DataValueFile(source);
+ return of(DataSource.of(source));
}
+ public static DataValueFile of(DataSource source) {
+ return new DataValueFile(source);
+ }
/**
* Creates a {@link DataValueFile} from a {@link SerializeFormat.DataValue}.
*/
@@ -66,20 +69,20 @@ public class DataValueFile implements DataResource, DataAsset {
}
@Override
- public Path source() {
+ public DataSource source() {
return source;
}
@Override
public void writeAsset(RelativeAssetPath key, AndroidDataWritingVisitor mergedDataWriter)
throws IOException {
- mergedDataWriter.copyAsset(source, key.toPathString());
+ mergedDataWriter.copyAsset(source.getPath(), key.toPathString());
}
@Override
public void writeResource(FullyQualifiedName key, AndroidDataWritingVisitor mergedDataWriter)
throws IOException, MergingException {
- mergedDataWriter.copyResource(source, key.toPathString(source));
+ mergedDataWriter.copyResource(source.getPath(), key.toPathString(source.getPath()));
}
@Override
diff --git a/src/tools/android/java/com/google/devtools/build/android/XmlResourceValue.java b/src/tools/android/java/com/google/devtools/build/android/XmlResourceValue.java
index 6818637220..35517ca245 100644
--- a/src/tools/android/java/com/google/devtools/build/android/XmlResourceValue.java
+++ b/src/tools/android/java/com/google/devtools/build/android/XmlResourceValue.java
@@ -16,7 +16,6 @@ package com.google.devtools.build.android;
import com.google.devtools.build.android.xml.Namespaces;
import java.io.IOException;
import java.io.OutputStream;
-import java.nio.file.Path;
/**
* An {@link XmlResourceValue} is extracted from xml files in the resource 'values' directory.
@@ -29,7 +28,7 @@ public interface XmlResourceValue {
* @param source The source of the value to allow for proper comment annotation.
* @param mergedDataWriter The target writer.
*/
- void write(FullyQualifiedName key, Path source, AndroidDataWritingVisitor mergedDataWriter);
+ void write(FullyQualifiedName key, DataSource source, AndroidDataWritingVisitor mergedDataWriter);
/** Serializes the resource value to the OutputStream and returns the bytes written. */
int serializeTo(int sourceId, Namespaces namespaces, OutputStream out) throws IOException;
diff --git a/src/tools/android/java/com/google/devtools/build/android/xml/ArrayXmlResourceValue.java b/src/tools/android/java/com/google/devtools/build/android/xml/ArrayXmlResourceValue.java
index f9cfd6a332..65e8e03e97 100644
--- a/src/tools/android/java/com/google/devtools/build/android/xml/ArrayXmlResourceValue.java
+++ b/src/tools/android/java/com/google/devtools/build/android/xml/ArrayXmlResourceValue.java
@@ -20,13 +20,13 @@ import com.google.common.collect.ImmutableMap;
import com.google.devtools.build.android.AndroidDataWritingVisitor;
import com.google.devtools.build.android.AndroidDataWritingVisitor.ValuesResourceDefinition;
import com.google.devtools.build.android.AndroidResourceClassWriter;
+import com.google.devtools.build.android.DataSource;
import com.google.devtools.build.android.FullyQualifiedName;
import com.google.devtools.build.android.XmlResourceValue;
import com.google.devtools.build.android.XmlResourceValues;
import com.google.devtools.build.android.proto.SerializeFormat;
import java.io.IOException;
import java.io.OutputStream;
-import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -119,7 +119,7 @@ public class ArrayXmlResourceValue implements XmlResourceValue {
@Override
public void write(
- FullyQualifiedName key, Path source, AndroidDataWritingVisitor mergedDataWriter) {
+ FullyQualifiedName key, DataSource source, AndroidDataWritingVisitor mergedDataWriter) {
ValuesResourceDefinition definition = mergedDataWriter.define(key).derivedFrom(source)
.startTag(arrayType.tagName)
.named(key)
diff --git a/src/tools/android/java/com/google/devtools/build/android/xml/AttrXmlResourceValue.java b/src/tools/android/java/com/google/devtools/build/android/xml/AttrXmlResourceValue.java
index cb74d3ca4f..e9578d6fa2 100644
--- a/src/tools/android/java/com/google/devtools/build/android/xml/AttrXmlResourceValue.java
+++ b/src/tools/android/java/com/google/devtools/build/android/xml/AttrXmlResourceValue.java
@@ -29,6 +29,7 @@ import com.google.devtools.build.android.AndroidDataWritingVisitor;
import com.google.devtools.build.android.AndroidDataWritingVisitor.StartTag;
import com.google.devtools.build.android.AndroidDataWritingVisitor.ValuesResourceDefinition;
import com.google.devtools.build.android.AndroidResourceClassWriter;
+import com.google.devtools.build.android.DataSource;
import com.google.devtools.build.android.FullyQualifiedName;
import com.google.devtools.build.android.XmlResourceValue;
import com.google.devtools.build.android.XmlResourceValues;
@@ -36,7 +37,6 @@ import com.google.devtools.build.android.proto.SerializeFormat;
import com.google.protobuf.InvalidProtocolBufferException;
import java.io.IOException;
import java.io.OutputStream;
-import java.nio.file.Path;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
@@ -289,7 +289,7 @@ public class AttrXmlResourceValue implements XmlResourceValue {
@Override
public void write(
- FullyQualifiedName key, Path source, AndroidDataWritingVisitor mergedDataWriter) {
+ FullyQualifiedName key, DataSource source, AndroidDataWritingVisitor mergedDataWriter) {
if (formats.isEmpty()) {
mergedDataWriter
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 5bd74f96ef..16bc0a5c07 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,7 +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.DataSource;
import com.google.devtools.build.android.FullyQualifiedName;
import com.google.devtools.build.android.XmlResourceValue;
import com.google.devtools.build.android.XmlResourceValues;
@@ -27,7 +27,6 @@ import com.google.devtools.build.android.proto.SerializeFormat.DataValueXml.XmlT
import com.google.protobuf.CodedOutputStream;
import java.io.IOException;
import java.io.OutputStream;
-import java.nio.file.Path;
import java.util.Objects;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
@@ -65,11 +64,11 @@ public class IdXmlResourceValue implements XmlResourceValue {
@Override
public void write(
- FullyQualifiedName key, Path source, AndroidDataWritingVisitor mergedDataWriter) {
- if (!DataResourceXml.isInValuesFolder(source)) {
+ FullyQualifiedName key, DataSource source, AndroidDataWritingVisitor mergedDataWriter) {
+ if (!source.isInValuesFolder()) {
/* 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
+ * DataSource#combine to accurately determine when a value is ever defined in a
* values file.
*/
return;
diff --git a/src/tools/android/java/com/google/devtools/build/android/xml/PluralXmlResourceValue.java b/src/tools/android/java/com/google/devtools/build/android/xml/PluralXmlResourceValue.java
index 7649117f05..c2fc64e24c 100644
--- a/src/tools/android/java/com/google/devtools/build/android/xml/PluralXmlResourceValue.java
+++ b/src/tools/android/java/com/google/devtools/build/android/xml/PluralXmlResourceValue.java
@@ -18,6 +18,7 @@ import com.google.common.collect.ImmutableMap;
import com.google.devtools.build.android.AndroidDataWritingVisitor;
import com.google.devtools.build.android.AndroidDataWritingVisitor.ValuesResourceDefinition;
import com.google.devtools.build.android.AndroidResourceClassWriter;
+import com.google.devtools.build.android.DataSource;
import com.google.devtools.build.android.FullyQualifiedName;
import com.google.devtools.build.android.XmlResourceValue;
import com.google.devtools.build.android.XmlResourceValues;
@@ -26,7 +27,6 @@ import com.google.devtools.build.android.proto.SerializeFormat.DataValueXml.XmlT
import com.google.protobuf.CodedOutputStream;
import java.io.IOException;
import java.io.OutputStream;
-import java.nio.file.Path;
import java.util.Map.Entry;
import java.util.Objects;
import javax.annotation.concurrent.Immutable;
@@ -72,7 +72,7 @@ public class PluralXmlResourceValue implements XmlResourceValue {
@Override
public void write(
- FullyQualifiedName key, Path source, AndroidDataWritingVisitor mergedDataWriter) {
+ FullyQualifiedName key, DataSource source, AndroidDataWritingVisitor mergedDataWriter) {
ValuesResourceDefinition definition =
mergedDataWriter
diff --git a/src/tools/android/java/com/google/devtools/build/android/xml/PublicXmlResourceValue.java b/src/tools/android/java/com/google/devtools/build/android/xml/PublicXmlResourceValue.java
index 9a0308dc7c..fe1ae7c927 100644
--- a/src/tools/android/java/com/google/devtools/build/android/xml/PublicXmlResourceValue.java
+++ b/src/tools/android/java/com/google/devtools/build/android/xml/PublicXmlResourceValue.java
@@ -22,13 +22,13 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import com.google.devtools.build.android.AndroidDataWritingVisitor;
import com.google.devtools.build.android.AndroidResourceClassWriter;
+import com.google.devtools.build.android.DataSource;
import com.google.devtools.build.android.FullyQualifiedName;
import com.google.devtools.build.android.XmlResourceValue;
import com.google.devtools.build.android.XmlResourceValues;
import com.google.devtools.build.android.proto.SerializeFormat;
import java.io.IOException;
import java.io.OutputStream;
-import java.nio.file.Path;
import java.util.EnumMap;
import java.util.Map;
import java.util.Map.Entry;
@@ -72,7 +72,7 @@ public class PublicXmlResourceValue implements XmlResourceValue {
@Override
public void write(
- FullyQualifiedName key, Path source, AndroidDataWritingVisitor mergedDataWriter) {
+ FullyQualifiedName key, DataSource source, AndroidDataWritingVisitor mergedDataWriter) {
for (Entry<ResourceType, Optional<Integer>> entry : typeToId.entrySet()) {
Integer value = entry.getValue().orNull();
mergedDataWriter
diff --git a/src/tools/android/java/com/google/devtools/build/android/xml/SimpleXmlResourceValue.java b/src/tools/android/java/com/google/devtools/build/android/xml/SimpleXmlResourceValue.java
index d6442a9e63..30adfd6d85 100644
--- a/src/tools/android/java/com/google/devtools/build/android/xml/SimpleXmlResourceValue.java
+++ b/src/tools/android/java/com/google/devtools/build/android/xml/SimpleXmlResourceValue.java
@@ -19,6 +19,7 @@ import com.google.common.collect.ImmutableMap;
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.DataSource;
import com.google.devtools.build.android.FullyQualifiedName;
import com.google.devtools.build.android.XmlResourceValue;
import com.google.devtools.build.android.XmlResourceValues;
@@ -26,7 +27,6 @@ import com.google.devtools.build.android.proto.SerializeFormat;
import com.google.devtools.build.android.proto.SerializeFormat.DataValueXml.Builder;
import java.io.IOException;
import java.io.OutputStream;
-import java.nio.file.Path;
import java.util.Arrays;
import java.util.Objects;
import javax.annotation.Nullable;
@@ -186,7 +186,7 @@ public class SimpleXmlResourceValue implements XmlResourceValue {
@Override
public void write(
- FullyQualifiedName key, Path source, AndroidDataWritingVisitor mergedDataWriter) {
+ FullyQualifiedName key, DataSource source, AndroidDataWritingVisitor mergedDataWriter) {
StartTag startTag =
mergedDataWriter
diff --git a/src/tools/android/java/com/google/devtools/build/android/xml/StyleXmlResourceValue.java b/src/tools/android/java/com/google/devtools/build/android/xml/StyleXmlResourceValue.java
index e539c98e5c..07d60ac636 100644
--- a/src/tools/android/java/com/google/devtools/build/android/xml/StyleXmlResourceValue.java
+++ b/src/tools/android/java/com/google/devtools/build/android/xml/StyleXmlResourceValue.java
@@ -19,6 +19,7 @@ import com.google.common.collect.ImmutableMap;
import com.google.devtools.build.android.AndroidDataWritingVisitor;
import com.google.devtools.build.android.AndroidDataWritingVisitor.ValuesResourceDefinition;
import com.google.devtools.build.android.AndroidResourceClassWriter;
+import com.google.devtools.build.android.DataSource;
import com.google.devtools.build.android.FullyQualifiedName;
import com.google.devtools.build.android.XmlResourceValue;
import com.google.devtools.build.android.XmlResourceValues;
@@ -26,7 +27,6 @@ import com.google.devtools.build.android.proto.SerializeFormat;
import com.google.devtools.build.android.proto.SerializeFormat.DataValueXml.XmlType;
import java.io.IOException;
import java.io.OutputStream;
-import java.nio.file.Path;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
@@ -79,7 +79,7 @@ public class StyleXmlResourceValue implements XmlResourceValue {
@Override
public void write(
- FullyQualifiedName key, Path source, AndroidDataWritingVisitor mergedDataWriter) {
+ FullyQualifiedName key, DataSource source, AndroidDataWritingVisitor mergedDataWriter) {
ValuesResourceDefinition definition =
mergedDataWriter
diff --git a/src/tools/android/java/com/google/devtools/build/android/xml/StyleableXmlResourceValue.java b/src/tools/android/java/com/google/devtools/build/android/xml/StyleableXmlResourceValue.java
index 822b43e9d4..6d90a0a0ff 100644
--- a/src/tools/android/java/com/google/devtools/build/android/xml/StyleableXmlResourceValue.java
+++ b/src/tools/android/java/com/google/devtools/build/android/xml/StyleableXmlResourceValue.java
@@ -22,6 +22,7 @@ import com.google.common.collect.Iterables;
import com.google.devtools.build.android.AndroidDataWritingVisitor;
import com.google.devtools.build.android.AndroidDataWritingVisitor.ValuesResourceDefinition;
import com.google.devtools.build.android.AndroidResourceClassWriter;
+import com.google.devtools.build.android.DataSource;
import com.google.devtools.build.android.FullyQualifiedName;
import com.google.devtools.build.android.XmlResourceValue;
import com.google.devtools.build.android.XmlResourceValues;
@@ -29,7 +30,6 @@ import com.google.devtools.build.android.proto.SerializeFormat;
import com.google.devtools.build.android.proto.SerializeFormat.DataValueXml.XmlType;
import java.io.IOException;
import java.io.OutputStream;
-import java.nio.file.Path;
import java.util.AbstractMap.SimpleEntry;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -110,7 +110,7 @@ public class StyleableXmlResourceValue implements XmlResourceValue {
@Override
public void write(
- FullyQualifiedName key, Path source, AndroidDataWritingVisitor mergedDataWriter) {
+ FullyQualifiedName key, DataSource source, AndroidDataWritingVisitor mergedDataWriter) {
ValuesResourceDefinition definition =
mergedDataWriter
.define(key)