in src/main/org/apache/ant/dotnet/NetCommand.java [360:414]
private void setExecutableCommandLine() {
String[] commands = commandLine.getCommandline();
//always trigger file mode if commands are big enough
if (automaticResponseFileThreshold > 0
&& commands.length > automaticResponseFileThreshold) {
useResponseFile = true;
}
if (!useResponseFile || commands.length <= 1) {
//the simple action is to send the command line in as is
executable.setCommandline(commands);
} else {
//but for big operations, we save all the params to a temp file
//and set @tmpfile as the command -then we remember to delete the tempfile
//afterwards
FileOutputStream fos = null;
temporaryCommandFile = FILE_UTILS.createTempFile("cmd", ".txt", null);
owner.log("Using response file " + temporaryCommandFile, Project.MSG_VERBOSE);
try {
fos = new FileOutputStream(temporaryCommandFile);
PrintWriter out = new PrintWriter(new BufferedOutputStream(fos));
//start at 1 because element 0 is the executable name
for (int i = 1; i < commands.length; ++i) {
if (argsOnCommandLine.contains(commands[i])) {
continue;
}
if (commands[i].indexOf(" ") > -1) {
String q = commands[i].indexOf("\"") > -1 ? "'" : "\"";
out.print(q);
out.print(commands[i]);
out.println(q);
} else {
out.println(commands[i]);
}
}
out.flush();
out.close();
} catch (IOException ex) {
throw new BuildException("saving command stream to " + temporaryCommandFile, ex);
}
String newCommandLine[] = new String[2 + argsOnCommandLine.size()];
newCommandLine[0] = commands[0];
if (argsOnCommandLine.size() > 0) {
System.arraycopy(argsOnCommandLine.toArray(), 0,
newCommandLine, 1, argsOnCommandLine.size());
}
newCommandLine[newCommandLine.length - 1] =
"@" + temporaryCommandFile.getAbsolutePath();
logVerbose(Commandline.describeCommand(newCommandLine));
executable.setCommandline(newCommandLine);
}
}