aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/tools/android/java/com/google/devtools/build/android/AarGeneratorAction.java
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2016-05-18 20:41:44 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2016-05-19 16:27:56 +0000
commit96314a5718b57590301a80cd6641e9d39a751e2f (patch)
tree4e7b3370c08d80bc219361ba558a6f3d7d74ea71 /src/tools/android/java/com/google/devtools/build/android/AarGeneratorAction.java
parentdab67e02488e2271b05da6c3750a9f8e95618ad5 (diff)
Use BufferedOutputStream for zipping / jar.
This is for the resources.zip and the srcjar and aar. For the srcjar this is only slightly faster (100ms), but we might as well? Perhaps this is because the files are quite large anyway. Not sure if there would be smaller writes with compression. For the resources.zip it seems to make a bigger difference: > 1s when run locally. Perhaps this is because there are more small files. Didn't benchmark aar at all, just noticed it. Kevin mentioned the Buffering on one of the issues, so I happened to notice this when using similar code for prototype of R.class jar creation (seemed to be > 1s faster in that case, but that was also compressing). -- MOS_MIGRATED_REVID=122663374
Diffstat (limited to 'src/tools/android/java/com/google/devtools/build/android/AarGeneratorAction.java')
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/AarGeneratorAction.java5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/tools/android/java/com/google/devtools/build/android/AarGeneratorAction.java b/src/tools/android/java/com/google/devtools/build/android/AarGeneratorAction.java
index 4880d1c77e..f84783a90b 100644
--- a/src/tools/android/java/com/google/devtools/build/android/AarGeneratorAction.java
+++ b/src/tools/android/java/com/google/devtools/build/android/AarGeneratorAction.java
@@ -29,8 +29,8 @@ import com.google.devtools.common.options.OptionsParser;
import com.android.ide.common.res2.MergingException;
import com.android.utils.StdLogger;
+import java.io.BufferedOutputStream;
import java.io.File;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
@@ -195,7 +195,8 @@ public class AarGeneratorAction {
@VisibleForTesting
static void writeAar(Path aar, final MergedAndroidData data, Path manifest, Path rtxt,
Path classes) throws IOException {
- try (final ZipOutputStream zipOut = new ZipOutputStream(new FileOutputStream(aar.toFile()))) {
+ try (final ZipOutputStream zipOut = new ZipOutputStream(
+ new BufferedOutputStream(Files.newOutputStream(aar)))) {
ZipEntry manifestEntry = new ZipEntry("AndroidManifest.xml");
manifestEntry.setTime(EPOCH);
zipOut.putNextEntry(manifestEntry);