aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/tools/android/java/com/google/devtools/build/android/AaptCommandBuilder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/android/java/com/google/devtools/build/android/AaptCommandBuilder.java')
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/AaptCommandBuilder.java25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/tools/android/java/com/google/devtools/build/android/AaptCommandBuilder.java b/src/tools/android/java/com/google/devtools/build/android/AaptCommandBuilder.java
index 6e9c9a41ab..ad645a6fdd 100644
--- a/src/tools/android/java/com/google/devtools/build/android/AaptCommandBuilder.java
+++ b/src/tools/android/java/com/google/devtools/build/android/AaptCommandBuilder.java
@@ -23,9 +23,11 @@ import com.google.common.io.CharStreams;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collection;
import java.util.List;
+import java.util.stream.Collectors;
import javax.annotation.Nullable;
/**
@@ -110,6 +112,29 @@ public class AaptCommandBuilder {
return this;
}
+ /**
+ * Adds a flag to the builder multiple times, once for each value in the given collection. {@code
+ * null} values will be skipped. If the collection is empty, nothing will be added. The values
+ * will be added in the source collection's iteration order. See {@link
+ * AaptCommandBuilder#addRepeated(String, Collection)} for more information. If the collection
+ * exceed 200 items, the values will be written to a file and passed as <flag&gt @<file>.
+ */
+ public AaptCommandBuilder addParameterableRepeated(
+ final String flag, Collection<String> values, Path workingDirectory) throws IOException {
+ Preconditions.checkNotNull(flag);
+ Preconditions.checkNotNull(workingDirectory);
+ if (values.size() > 200) {
+ add(
+ flag,
+ "@" + Files.write(
+ Files.createDirectories(workingDirectory).resolve("params" + flag),
+ ImmutableList.of(values.stream().collect(Collectors.joining(" ")))));
+ } else {
+ addRepeated(flag, values);
+ }
+ return this;
+ }
+
/** Adds the next flag to the builder only if the condition is true. */
public ConditionalAaptCommandBuilder when(boolean condition) {
if (condition) {