Always use deferred param files for resource jars
@@ -18,8 +18,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Streams;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.actions.ParamFileInfo;
import com.google.devtools.build.lib.actions.ParameterFile.ParameterFileType;
@@ -37,6 +35,9 @@ import java.util.Map;
public class ResourceJarActionBuilder {
public static final String MNEMONIC = "JavaResourceJar";
+ private static final ParamFileInfo PARAM_FILE_INFO =
+ ParamFileInfo.builder(ParameterFileType.SHELL_QUOTED).build();
+
private Artifact outputJar;
private Map<PathFragment, Artifact> resources = ImmutableMap.of();
private NestedSet<Artifact> resourceJars = NestedSetBuilder.emptySet(Order.STABLE_ORDER);
@@ -124,18 +125,6 @@ public class ResourceJarActionBuilder {
if (!classpathResources.isEmpty()) {
command.addExecPaths("--classpath_resources", classpathResources);
}
- ParamFileInfo paramFileInfo = null;
- // TODO(b/37444705): remove this logic and always call useParameterFile once the bug is fixed
- // Most resource jar actions are very small and expanding the argument list for
- // ParamFileHelper#getParamsFileMaybe is expensive, so avoid doing that work if
- // we definitely don't need a params file.
- // This heuristic could be much more aggressive, but we don't ever want to skip
- // the params file in situations where it is required for --min_param_file_size.
- if (sizeGreaterThanOrEqual(
- Iterables.concat(messages, resources.values(), resourceJars, classpathResources), 10)
- || ruleContext.getConfiguration().getCommandLineLimits().maxLength < 10000) {
- paramFileInfo = ParamFileInfo.builder(ParameterFileType.SHELL_QUOTED).build();
- }
ruleContext.registerAction(
builder
.addOutput(outputJar)
@@ -144,16 +133,12 @@ public class ResourceJarActionBuilder {
.addTransitiveInputs(resourceJars)
.addTransitiveInputs(additionalInputs)
.addInputs(classpathResources)
- .addCommandLine(command.build(), paramFileInfo)
+ .addCommandLine(command.build(), PARAM_FILE_INFO)
.setProgressMessage("Building Java resource jar")
.setMnemonic(MNEMONIC)
.build(ruleContext));
}
- boolean sizeGreaterThanOrEqual(Iterable<?> elements, int size) {
- return Streams.stream(elements).limit(size).count() == size;
- }
-
private static void addAsResourcePrefixedExecPath(
PathFragment resourcePath, Artifact artifact, CustomCommandLine.Builder builder) {
PathFragment execPath = artifact.getExecPath();
