Add helper constructor to Resource provider.
This will implicitly use the passed in path as a PathOrigin
Change-Id: I51fec8fcaf87189bdd2e7bcf64301633c86e13b0
diff --git a/src/main/java/com/android/tools/r8/ArchiveProtoAndroidResourceProvider.java b/src/main/java/com/android/tools/r8/ArchiveProtoAndroidResourceProvider.java
index e67c735..ca4321e 100644
--- a/src/main/java/com/android/tools/r8/ArchiveProtoAndroidResourceProvider.java
+++ b/src/main/java/com/android/tools/r8/ArchiveProtoAndroidResourceProvider.java
@@ -7,6 +7,7 @@
import com.android.tools.r8.keepanno.annotations.KeepForApi;
import com.android.tools.r8.origin.ArchiveEntryOrigin;
import com.android.tools.r8.origin.Origin;
+import com.android.tools.r8.origin.PathOrigin;
import com.android.tools.r8.utils.FileUtils;
import com.google.common.io.ByteStreams;
import java.io.ByteArrayInputStream;
@@ -49,6 +50,15 @@
this.origin = origin;
}
+ /**
+ * Creates an android resource provider from an archive.
+ *
+ * @param archive Zip archive to provide resources from.
+ */
+ public ArchiveProtoAndroidResourceProvider(Path archive) {
+ this(archive, new PathOrigin(archive));
+ }
+
@Override
public Collection<AndroidResourceInput> getAndroidResources() throws ResourceException {
try (ZipFile zipFile = FileUtils.createZipFile(archive.toFile(), StandardCharsets.UTF_8)) {
diff --git a/src/main/java/com/android/tools/r8/R8CommandParser.java b/src/main/java/com/android/tools/r8/R8CommandParser.java
index fa0a094..e3d5927 100644
--- a/src/main/java/com/android/tools/r8/R8CommandParser.java
+++ b/src/main/java/com/android/tools/r8/R8CommandParser.java
@@ -308,8 +308,7 @@
} else if (arg.equals("--android-resources")) {
Path inputPath = Paths.get(nextArg);
Path outputPath = Paths.get(nextNextArg);
- builder.setAndroidResourceProvider(
- new ArchiveProtoAndroidResourceProvider(inputPath, new PathOrigin(inputPath)));
+ builder.setAndroidResourceProvider(new ArchiveProtoAndroidResourceProvider(inputPath));
builder.setAndroidResourceConsumer(
new ArchiveProtoAndroidResourceConsumer(outputPath, inputPath));
} else if (arg.equals("--feature")) {
diff --git a/src/test/testbase/java/com/android/tools/r8/R8TestBuilder.java b/src/test/testbase/java/com/android/tools/r8/R8TestBuilder.java
index 3412d54..7ef9b00 100644
--- a/src/test/testbase/java/com/android/tools/r8/R8TestBuilder.java
+++ b/src/test/testbase/java/com/android/tools/r8/R8TestBuilder.java
@@ -966,9 +966,7 @@
Path resourceZip = testResource.getResourceZip();
featureSplitGenerator
.setAndroidResourceConsumer(new ArchiveProtoAndroidResourceConsumer(outputFile))
- .setAndroidResourceProvider(
- new ArchiveProtoAndroidResourceProvider(
- resourceZip, new PathOrigin(resourceZip)))
+ .setAndroidResourceProvider(new ArchiveProtoAndroidResourceProvider(resourceZip))
.setProgramConsumer(DexIndexedConsumer.emptyConsumer());
return featureSplitGenerator.build();
@@ -997,10 +995,10 @@
AndroidTestResource testResource) {
Path resources = testResource.getResourceZip();
if (testResource.getAdditionalKeepRuleFiles().isEmpty()) {
- return new ArchiveProtoAndroidResourceProvider(resources, new PathOrigin(resources));
+ return new ArchiveProtoAndroidResourceProvider(resources);
}
ArchiveProtoAndroidResourceProvider provider =
- new ArchiveProtoAndroidResourceProvider(resources, new PathOrigin(resources)) {
+ new ArchiveProtoAndroidResourceProvider(resources) {
@Override
public Collection<AndroidResourceInput> getAndroidResources() throws ResourceException {
ArrayList<AndroidResourceInput> resourceInputs =