From 21f117ae6599b48719faa55064a745e5ff695865 Mon Sep 17 00:00:00 2001 From: Googler Date: Fri, 15 Dec 2017 16:14:03 -0800 Subject: 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 --- .../devtools/build/android/ResourcesZip.java | 49 +++------------------- 1 file changed, 5 insertions(+), 44 deletions(-) (limited to 'src/tools/android/java/com/google/devtools/build/android/ResourcesZip.java') 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 apkWithAssets; private final Optional ids; - private ResourcesZip( - Path resourcesRoot, - Path assetsRoot, - Optional ids, - Optional apkWithAssets) { + private ResourcesZip(Path resourcesRoot, Path assetsRoot, Optional 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)); } -- cgit v1.2.3