aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2015-11-20 19:02:37 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2015-11-20 21:06:33 +0000
commit32656c4e90392997a6bb54b41cc2b5dff74e32df (patch)
tree6ed00f2a8dd73043023a0841617f12bf66ec3890 /src
parentc4e4bb49e3a8ecd75040a38b7c0f507ed125912e (diff)
re-add support for multiple R.txt files with different packages.
-- MOS_MIGRATED_REVID=108359590
Diffstat (limited to 'src')
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/ResourceShrinker.java36
1 files changed, 25 insertions, 11 deletions
diff --git a/src/tools/android/java/com/google/devtools/build/android/ResourceShrinker.java b/src/tools/android/java/com/google/devtools/build/android/ResourceShrinker.java
index 8b331ffac3..f12f0fee01 100644
--- a/src/tools/android/java/com/google/devtools/build/android/ResourceShrinker.java
+++ b/src/tools/android/java/com/google/devtools/build/android/ResourceShrinker.java
@@ -121,11 +121,10 @@ import javax.xml.parsers.ParserConfigurationException;
public class ResourceShrinker {
public static final int TYPICAL_RESOURCE_COUNT = 200;
- private final Path rTxt;
+ private List<ResourceFile> resourceFiles;
private final Path classesJar;
private final Path mergedManifest;
private final Path mergedResourceDir;
- private final String rPackagePath;
/**
* The computed set of unused resources
@@ -152,22 +151,31 @@ public class ResourceShrinker {
*/
private Map<String, ResourceType> resourceClassOwners = Maps.newHashMapWithExpectedSize(20);
+ public static class ResourceFile {
+
+ public ResourceFile(Path rTxt, String packageName) {
+ this.rTxt = rTxt;
+ this.packageName = packageName;
+ }
+
+ @NonNull Path rTxt;
+ @NonNull String packageName;
+ }
+
public ResourceShrinker(
- @NonNull Path rTxt,
+ List<ResourceFile> resourceFiles,
@NonNull Path classesJar,
@NonNull Path manifest,
- @NonNull Path resources,
- @NonNull String rPackageName) {
- this.rTxt = rTxt;
+ @NonNull Path resources) {
+ this.resourceFiles = resourceFiles;
this.classesJar = classesJar;
- mergedManifest = manifest;
- mergedResourceDir = resources;
- this.rPackagePath = rPackageName.replace('.', '/');
+ this.mergedManifest = manifest;
+ this.mergedResourceDir = resources;
}
public void shrink(Path destinationDir) throws IOException,
ParserConfigurationException, SAXException {
- parseResourceTxtFile(rTxt);
+ parseResources(resourceFiles);
recordUsages(classesJar);
recordManifestUsages(mergedManifest);
recordResources(mergedResourceDir);
@@ -857,7 +865,13 @@ public class ResourceShrinker {
}
}
- private void parseResourceTxtFile(Path file) throws IOException {
+ private void parseResources(List<ResourceFile> resourceFiles) throws IOException {
+ for (ResourceFile resourceFile : resourceFiles) {
+ parseResourceTxtFile(resourceFile.rTxt, resourceFile.packageName.replace('.', '/'));
+ }
+ }
+
+ private void parseResourceTxtFile(Path file, String rPackagePath) throws IOException {
BufferedReader reader = java.nio.file.Files.newBufferedReader(file, Charset.defaultCharset());
String line;
while ((line = reader.readLine()) != null) {