Skip to content

Commit

Permalink
Allow long non-file arguments to be spilled
Browse files Browse the repository at this point in the history
Allow long non-file arguments (e.g. -classpath) to go to a file.  This
prevents E2BIG when the classpath argument is too long.

This can't easily be fixed in upstream ant because:
(a) it would require an API change, and
(b) there is no way for ant to know which arguments are safe to spill

Fixes #671

RELNOTES: N/A

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167726515
  • Loading branch information
novalis authored and ronshapiro committed Sep 6, 2017
1 parent 8d3584d commit 8d570cb
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,14 @@ public boolean execute() throws BuildException {
}

cmd.createArgument().setValue(ErrorProneCompiler.class.getName());
// This is the first argument that may be spilled to a file.
// The ant API describes it as the first argument which is a
// file, but in fact only uses it for spilling. Putting the
// break here allows long classpath arguments to be handled.
int firstSpillableArgument = cmd.size();
setupModernJavacCommandlineSwitches(cmd);
int firstFile = cmd.size();
logAndAddFilesToCompile(cmd);
return executeExternalCompile(cmd.getCommandline(), firstFile, true) == 0;
return executeExternalCompile(cmd.getCommandline(), firstSpillableArgument, true) == 0;
} else {
attributes.log(
"You must set fork=\"yes\" to use the external Error Prone compiler", Project.MSG_ERR);
Expand Down

0 comments on commit 8d570cb

Please sign in to comment.