Stop using CustomMultiArgv in OneVersionCheckActionBuilder.
@@ -16,13 +16,11 @@ package com.google.devtools.build.lib.rules.java;
import static com.google.devtools.build.lib.util.Preconditions.checkNotNull;
-import com.google.common.base.Joiner;
-import com.google.common.collect.ImmutableList;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.actions.ParameterFile.ParameterFileType;
import com.google.devtools.build.lib.analysis.RuleContext;
import com.google.devtools.build.lib.analysis.actions.CustomCommandLine;
-import com.google.devtools.build.lib.analysis.actions.CustomCommandLine.CustomMultiArgv;
+import com.google.devtools.build.lib.analysis.actions.CustomCommandLine.VectorArg;
import com.google.devtools.build.lib.analysis.actions.SpawnAction;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
@@ -94,7 +92,8 @@ public final class OneVersionCheckActionBuilder {
if (enforcementLevel == OneVersionEnforcementLevel.WARNING) {
oneVersionArgsBuilder.add("--succeed_on_found_violations");
}
- oneVersionArgsBuilder.addCustomMultiArgv(new OneVersionJarMapArgv(jarsToCheck));
+ oneVersionArgsBuilder.add("--inputs", VectorArg.of(jarsToCheck).mapEach(
+ OneVersionCheckActionBuilder::jarAndTargetArg));
CustomCommandLine oneVersionArgs = oneVersionArgsBuilder.build();
ruleContext.registerAction(
new SpawnAction.Builder()
@@ -110,25 +109,8 @@ public final class OneVersionCheckActionBuilder {
return outputArtifact;
}
- private static class OneVersionJarMapArgv extends CustomMultiArgv {
-
- private static final Joiner COMMA_JOINER = Joiner.on(',');
- private final Iterable<Artifact> classPathJars;
-
- private OneVersionJarMapArgv(Iterable<Artifact> classPathJars) {
- this.classPathJars = classPathJars;
- }
-
- @Override
- public Iterable<String> argv() {
- ImmutableList.Builder<String> args = ImmutableList.builder();
- args.add("--inputs");
- for (Artifact classPathJar : classPathJars) {
- args.add(
- COMMA_JOINER.join(
- classPathJar.getExecPathString(), getArtifactOwnerGeneralizedLabel(classPathJar)));
- }
- return args.build();
+ private static String jarAndTargetArg(Artifact jar) {
+ return jar.getExecPathString() + "," + getArtifactOwnerGeneralizedLabel(jar);
}
private static String getArtifactOwnerGeneralizedLabel(Artifact artifact) {
@@ -141,4 +123,3 @@ public final class OneVersionCheckActionBuilder {
: "@" + label;
}
}
-}
