diff --git a/src/test/java/com/google/devtools/build/android/AarGeneratorActionTest.java b/src/test/java/com/google/devtools/build/android/AarGeneratorActionTest.java index 794fbcf90b675d..296ec686dc12bd 100644 --- a/src/test/java/com/google/devtools/build/android/AarGeneratorActionTest.java +++ b/src/test/java/com/google/devtools/build/android/AarGeneratorActionTest.java @@ -676,7 +676,6 @@ private Set getZipEntryTimestamps(Path zip) throws IOException { ImmutableList.of(), resourcesOut, assetsOut, - null, VariantType.LIBRARY, null, /* filteredResources= */ ImmutableList.of(), diff --git a/src/test/java/com/google/devtools/build/android/AndroidDataWriterTest.java b/src/test/java/com/google/devtools/build/android/AndroidDataWriterTest.java index 8698750bac6f49..cd5a5a991e800d 100644 --- a/src/test/java/com/google/devtools/build/android/AndroidDataWriterTest.java +++ b/src/test/java/com/google/devtools/build/android/AndroidDataWriterTest.java @@ -14,16 +14,11 @@ package com.google.devtools.build.android; import static com.google.common.truth.Truth.assertAbout; -import static com.google.common.truth.Truth.assertThat; -import com.android.ide.common.internal.PngCruncher; -import com.android.ide.common.internal.PngException; import com.google.common.collect.ImmutableMap; import com.google.common.jimfs.Jimfs; import com.google.common.truth.Subject; import com.google.common.util.concurrent.MoreExecutors; -import java.io.File; -import java.io.IOException; import java.nio.file.FileSystem; import java.nio.file.Files; import java.nio.file.Path; @@ -83,27 +78,6 @@ public void writePngInRawAndNotInRaw() throws Exception { target, target.resolve("res"), target.resolve("assets"), - new PngCruncher() { - @Override - public int start() { - return 0; - } - - @Override - public void end(int key) throws InterruptedException { - } - - @Override - public void crunchPng(int key, File from, File to) - throws PngException { - assertThat(from.toString()).doesNotContain(raw); - try { - Files.copy(from.toPath(), to.toPath()); - } catch (IOException e) { - throw new PngException(e); - } - } - }, MoreExecutors.newDirectExecutorService()); ParsedAndroidData direct = AndroidDataBuilder.of(source) 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 b277fdcd40626f..6a3b969505c7e3 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 @@ -187,7 +187,6 @@ public static void main(String[] args) throws IOException { ImmutableList.of(), resourcesOut, assetsOut, - null, VariantType.LIBRARY, null, /* filteredResources= */ ImmutableList.of(), diff --git a/src/tools/android/java/com/google/devtools/build/android/AndroidAssetMergingAction.java b/src/tools/android/java/com/google/devtools/build/android/AndroidAssetMergingAction.java index 6d871a65c55041..2939e80701846a 100644 --- a/src/tools/android/java/com/google/devtools/build/android/AndroidAssetMergingAction.java +++ b/src/tools/android/java/com/google/devtools/build/android/AndroidAssetMergingAction.java @@ -141,7 +141,6 @@ void run(Path tmp, ExecutorServiceCloser executorService) throws Exception { options.transitiveData, /* resourcesOut = */ ignored, mergedAssets, - /* cruncher = */ null, VariantType.LIBRARY, /* symbolsOut = */ null, /* rclassWriter = */ null, diff --git a/src/tools/android/java/com/google/devtools/build/android/AndroidDataWriter.java b/src/tools/android/java/com/google/devtools/build/android/AndroidDataWriter.java index 4aaeb3cf98c751..a67ab4507c335a 100644 --- a/src/tools/android/java/com/google/devtools/build/android/AndroidDataWriter.java +++ b/src/tools/android/java/com/google/devtools/build/android/AndroidDataWriter.java @@ -13,10 +13,6 @@ // limitations under the License. package com.google.devtools.build.android; -import com.android.SdkConstants; -import com.android.annotations.NonNull; -import com.android.ide.common.internal.PngCruncher; -import com.android.ide.common.internal.PngException; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Joiner; import com.google.common.base.Preconditions; @@ -27,13 +23,8 @@ import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.MoreExecutors; -import com.google.devtools.build.android.AndroidResourceMerger.MergingException; -import com.google.devtools.build.android.junctions.JunctionCreator; -import com.google.devtools.build.android.junctions.NoopJunctionCreator; -import com.google.devtools.build.android.junctions.WindowsJunctionCreator; import com.google.devtools.build.android.xml.Namespaces; import java.io.BufferedWriter; -import java.io.File; import java.io.IOException; import java.io.Writer; import java.nio.charset.StandardCharsets; @@ -58,32 +49,6 @@ /** Writer for UnwrittenMergedAndroidData. */ public class AndroidDataWriter implements AndroidDataWritingVisitor { - private static final class CrunchTask implements Callable { - private final Path destinationPath; - private final Path source; - private final PngCruncher cruncher; - - private CrunchTask(PngCruncher cruncher, Path destinationPath, Path source) { - this.cruncher = cruncher; - this.destinationPath = destinationPath; - this.source = source; - } - - @Override - public Boolean call() throws Exception { - try (JunctionCreator junc = - System.getProperty("os.name").toLowerCase().startsWith("windows") - ? new WindowsJunctionCreator(Files.createTempDirectory("pngcrunch")) - : new NoopJunctionCreator()) { - Files.createDirectories(destinationPath.getParent()); - cruncher.crunchPng(0, junc.create(source).toFile(), junc.create(destinationPath).toFile()); - } catch (PngException e) { - throw MergingException.wrapException(e); - } - return Boolean.TRUE; - } - } - private static final class CopyTask implements Callable { private final Path sourcePath; @@ -108,34 +73,12 @@ public Boolean call() throws Exception { private static final char[] START_RESOURCES_TAG = " valueTags = new LinkedHashMap<>(); private final Path resourceDirectory; private final Path assetDirectory; - private final PngCruncher cruncher; private final List> writeTasks = new ArrayList<>(); private final ListeningExecutorService executorService; @@ -143,12 +86,10 @@ private AndroidDataWriter( Path destination, Path resourceDirectory, Path assetsDirectory, - PngCruncher cruncher, ListeningExecutorService executorService) { this.destination = destination; this.resourceDirectory = resourceDirectory; this.assetDirectory = assetsDirectory; - this.cruncher = cruncher; this.executorService = executorService; } @@ -156,7 +97,7 @@ private AndroidDataWriter( * Creates a new, naive writer for testing. * *

This writer has "assets" and a "res" directory from the destination directory, as well as a - * noop png cruncher and a {@link ExecutorService} of 1 thread. + * {@link ExecutorService} of 1 thread. * * @param destination The base directory to derive all paths. * @return A new {@link AndroidDataWriter}. @@ -167,7 +108,6 @@ static AndroidDataWriter createWithDefaults(Path destination) { destination, destination.resolve("res"), destination.resolve("assets"), - NOOP_CRUNCHER, MoreExecutors.newDirectExecutorService()); } @@ -177,8 +117,6 @@ static AndroidDataWriter createWithDefaults(Path destination) { * @param manifestDirectory The base directory for the AndroidManifest. * @param resourceDirectory The directory to copy resources into. * @param assetsDirectory The directory to copy assets into. - * @param cruncher The cruncher for png files. If the cruncher is null, it will be replaced with a - * noop cruncher. * @param executorService An execution service for multi-threaded writing. * @return A new {@link AndroidDataWriter}. */ @@ -186,13 +124,11 @@ public static AndroidDataWriter createWith( Path manifestDirectory, Path resourceDirectory, Path assetsDirectory, - @Nullable PngCruncher cruncher, ListeningExecutorService executorService) { return new AndroidDataWriter( manifestDirectory, resourceDirectory, assetsDirectory, - cruncher == null ? NOOP_CRUNCHER : cruncher, executorService); } @@ -219,15 +155,9 @@ public void copyAsset(Path source, String relativeDestinationPath) throws IOExce } @Override - public void copyResource(final Path source, final String relativeDestinationPath) - throws MergingException { + public void copyResource(final Path source, final String relativeDestinationPath) { final Path destinationPath = resourceDirectory.resolve(relativeDestinationPath); - if (!source.getParent().getFileName().toString().startsWith(SdkConstants.FD_RES_RAW) - && source.getFileName().toString().endsWith(SdkConstants.DOT_PNG)) { - writeTasks.add(executorService.submit(new CrunchTask(cruncher, destinationPath, source))); - } else { - copy(source, destinationPath); - } + copy(source, destinationPath); } private void copy(final Path sourcePath, final Path destinationPath) { diff --git a/src/tools/android/java/com/google/devtools/build/android/AndroidResourceMerger.java b/src/tools/android/java/com/google/devtools/build/android/AndroidResourceMerger.java index 37deb219d63a66..479be5176a2116 100644 --- a/src/tools/android/java/com/google/devtools/build/android/AndroidResourceMerger.java +++ b/src/tools/android/java/com/google/devtools/build/android/AndroidResourceMerger.java @@ -15,7 +15,6 @@ import com.android.annotations.Nullable; import com.android.builder.core.VariantType; -import com.android.ide.common.internal.PngCruncher; import com.google.common.base.Stopwatch; import com.google.common.collect.ImmutableList; import com.google.common.util.concurrent.ListeningExecutorService; @@ -92,7 +91,6 @@ public static MergedAndroidData mergeDataAndWrite( final List transitive, final Path resourcesOut, final Path assetsOut, - @Nullable final PngCruncher cruncher, final VariantType type, @Nullable final Path symbolsOut, final List filteredResources, @@ -106,7 +104,6 @@ public static MergedAndroidData mergeDataAndWrite( transitive, resourcesOut, assetsOut, - cruncher, type, symbolsOut, /* rclassWriter= */ null, @@ -129,7 +126,6 @@ public static MergedAndroidData mergeDataAndWrite( final List transitive, final Path resourcesOut, final Path assetsOut, - @Nullable final PngCruncher cruncher, final VariantType type, @Nullable final Path symbolsOut, @Nullable final AndroidResourceClassWriter rclassWriter, @@ -147,7 +143,6 @@ public static MergedAndroidData mergeDataAndWrite( transitive, resourcesOut, assetsOut, - cruncher, type, symbolsOut, rclassWriter, @@ -164,7 +159,6 @@ private static MergedAndroidData mergeDataAndWrite( final List transitive, final Path resourcesOut, final Path assetsOut, - @Nullable final PngCruncher cruncher, final VariantType type, @Nullable final Path symbolsOut, @Nullable AndroidResourceClassWriter rclassWriter, @@ -202,7 +196,7 @@ private static MergedAndroidData mergeDataAndWrite( } AndroidDataWriter writer = AndroidDataWriter.createWith( - resourcesOut.getParent(), resourcesOut, assetsOut, cruncher, executorService); + resourcesOut.getParent(), resourcesOut, assetsOut, executorService); return merged.write(writer); } catch (IOException e) { throw MergingException.wrapException(e); diff --git a/src/tools/android/java/com/google/devtools/build/android/NinePatchOnlyCruncher.java b/src/tools/android/java/com/google/devtools/build/android/NinePatchOnlyCruncher.java deleted file mode 100644 index d497b0d2d6e80c..00000000000000 --- a/src/tools/android/java/com/google/devtools/build/android/NinePatchOnlyCruncher.java +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2016 The Bazel Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -package com.google.devtools.build.android; - -import com.android.SdkConstants; -import com.android.ide.common.internal.AaptCruncher; -import com.android.ide.common.internal.PngException; -import com.android.ide.common.process.ProcessExecutor; -import com.android.ide.common.process.ProcessOutputHandler; -import com.google.common.io.Files; -import java.io.File; -import java.io.IOException; - -/** A wrapper around a PNG cruncher that only processes nine-patch PNGs. */ -public class NinePatchOnlyCruncher extends AaptCruncher { - - public NinePatchOnlyCruncher( - String aaptLocation, - ProcessExecutor processExecutor, - ProcessOutputHandler processOutputHandler) { - super(aaptLocation, processExecutor, processOutputHandler); - } - - /** - * Runs the cruncher on a single file (or copies the file if no crunching is needed). - * - * @param from the file to process - * @param to the output file - */ - @Override - public void crunchPng(int key, File from, File to) throws PngException { - if (from.getPath().endsWith(SdkConstants.DOT_9PNG)) { - super.crunchPng(0, from, to); - } else { - try { - Files.copy(from, to); - } catch (IOException e) { - throw new PngException(e); - } - } - } -}