diff options
author | Googler <noreply@google.com> | 2017-12-15 16:14:03 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2017-12-15 16:16:04 -0800 |
commit | 21f117ae6599b48719faa55064a745e5ff695865 (patch) | |
tree | 0b556338985fcb52b5290d699dd3a77f6f96a92b /src/tools/android/java/com/google/devtools/build/android/ResourcesZip.java | |
parent | dd6f8298529f05372d9c0c31eabf19f69d38b22e (diff) |
Automated rollback of commit 70c2be189c9c0021f7c424c7399f8bdecc579b4e.
*** Reason for rollback ***
Broke some cakemix tap projects
*** Original change description ***
Use assets from the APK for resource shrinking rather than from the merge actions.
RELNOTES: none
PiperOrigin-RevId: 179252805
Diffstat (limited to 'src/tools/android/java/com/google/devtools/build/android/ResourcesZip.java')
-rw-r--r-- | src/tools/android/java/com/google/devtools/build/android/ResourcesZip.java | 49 |
1 files changed, 5 insertions, 44 deletions
diff --git a/src/tools/android/java/com/google/devtools/build/android/ResourcesZip.java b/src/tools/android/java/com/google/devtools/build/android/ResourcesZip.java index 5f2b644178..edb254434c 100644 --- a/src/tools/android/java/com/google/devtools/build/android/ResourcesZip.java +++ b/src/tools/android/java/com/google/devtools/build/android/ResourcesZip.java @@ -41,18 +41,12 @@ public class ResourcesZip { private final Path resourcesRoot; private final Path assetsRoot; - private final Optional<Path> apkWithAssets; private final Optional<Path> ids; - private ResourcesZip( - Path resourcesRoot, - Path assetsRoot, - Optional<Path> ids, - Optional<Path> apkWithAssets) { + private ResourcesZip(Path resourcesRoot, Path assetsRoot, Optional<Path> ids) { this.resourcesRoot = resourcesRoot; this.assetsRoot = assetsRoot; this.ids = ids; - this.apkWithAssets = apkWithAssets; } /** @@ -60,7 +54,7 @@ public class ResourcesZip { * @param assetsRoot The root of the raw assets. */ public static ResourcesZip from(Path resourcesRoot, Path assetsRoot) { - return new ResourcesZip(resourcesRoot, assetsRoot, Optional.empty(), Optional.empty()); + return new ResourcesZip(resourcesRoot, assetsRoot, Optional.empty()); } /** @@ -70,23 +64,7 @@ public class ResourcesZip { */ public static ResourcesZip from(Path resourcesRoot, Path assetsRoot, Path resourceIds) { return new ResourcesZip( - resourcesRoot, - assetsRoot, - Optional.of(resourceIds).filter(Files::exists), - Optional.empty()); - } - - /** - * @param resourcesRoot The root of the raw resources. - * @param apkWithAssets The apk containing assets. - * @param resourceIds Optional path to a file containing the resource ids. - */ - public static ResourcesZip fromApk(Path resourcesRoot, Path apkWithAssets, Path resourceIds) { - return new ResourcesZip( - resourcesRoot, - null /* assetsRoot */, - Optional.of(resourceIds).filter(Files::exists), - Optional.of(apkWithAssets)); + resourcesRoot, assetsRoot, Optional.of(resourceIds).filter(Files::exists)); } /** Creates a ResourcesZip from an archive by expanding into the workingDirectory. */ @@ -138,24 +116,7 @@ public class ResourcesZip { } visitor.writeEntries(); } - - if (apkWithAssets.isPresent()){ - ZipFile apkZip = new ZipFile(apkWithAssets.get().toString()); - apkZip - .stream() - .filter(entry -> entry.getName().startsWith("assets/")) - .forEach( - entry -> { - try { - zip.addEntry( - entry, - ByteStreams.toByteArray(apkZip.getInputStream(entry))); - } catch (IOException e) { - throw new RuntimeException(e); - } - }); - zip.addEntry("assets/", new byte[0], ZipEntry.STORED); - } else if (Files.exists(assetsRoot)) { + if (Files.exists(assetsRoot)) { ZipBuilderVisitorWithDirectories visitor = new ZipBuilderVisitorWithDirectories(zip, assetsRoot, "assets"); visitor.setCompress(compress); @@ -189,7 +150,7 @@ public class ResourcesZip { packages, rTxt, classJar, manifest, proguardMapping, resourcesRoot, logFile) .shrink(workingDirectory); return ShrunkResources.of( - new ResourcesZip(workingDirectory, assetsRoot, ids, Optional.empty()), + new ResourcesZip(workingDirectory, assetsRoot, ids), new UnvalidatedAndroidData( ImmutableList.of(workingDirectory), ImmutableList.of(assetsRoot), manifest)); } |