something completely different. I hope this will cut down the "Ant swallows my quotes" reports to those that are real problems in Ant and not just problems of communication. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272573 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -55,6 +55,7 @@ | |||||
| package org.apache.tools.ant; | package org.apache.tools.ant; | ||||
| import java.io.PrintStream; | import java.io.PrintStream; | ||||
| import java.util.StringTokenizer; | |||||
| import org.apache.tools.ant.util.StringUtils; | import org.apache.tools.ant.util.StringUtils; | ||||
| import org.apache.tools.ant.util.DateUtils; | import org.apache.tools.ant.util.DateUtils; | ||||
| @@ -248,21 +249,34 @@ public class DefaultLogger implements BuildLogger { | |||||
| if (priority <= msgOutputLevel) { | if (priority <= msgOutputLevel) { | ||||
| StringBuffer message = new StringBuffer(); | StringBuffer message = new StringBuffer(); | ||||
| // Print out the name of the task if we're in one | |||||
| if (event.getTask() != null) { | |||||
| if (event.getTask() != null && !emacsMode) { | |||||
| // Print out the name of the task if we're in one | |||||
| String name = event.getTask().getTaskName(); | String name = event.getTask().getTaskName(); | ||||
| String label = "[" + name + "] "; | |||||
| int size = LEFT_COLUMN_SIZE - label.length(); | |||||
| StringBuffer tmp = new StringBuffer(size); | |||||
| for (int i = 0; i < size; i++) { | |||||
| tmp.append(" "); | |||||
| } | |||||
| tmp.append(label); | |||||
| label = tmp.toString(); | |||||
| if (!emacsMode) { | |||||
| String label = "[" + name + "] "; | |||||
| int size = LEFT_COLUMN_SIZE - label.length(); | |||||
| for (int i = 0; i < size; i++) { | |||||
| message.append(" "); | |||||
| StringTokenizer tok = new StringTokenizer(event.getMessage(), | |||||
| "\r\n", false); | |||||
| boolean first = true; | |||||
| while (tok.hasMoreTokens()) { | |||||
| if (!first) { | |||||
| message.append(StringUtils.LINE_SEP); | |||||
| } | } | ||||
| first = false; | |||||
| message.append(label); | message.append(label); | ||||
| message.append(tok.nextToken()); | |||||
| } | } | ||||
| } else { | |||||
| message.append(event.getMessage()); | |||||
| } | } | ||||
| message.append(event.getMessage()); | |||||
| String msg = message.toString(); | String msg = message.toString(); | ||||
| if (priority != Project.MSG_ERR) { | if (priority != Project.MSG_ERR) { | ||||
| printMessage(msg, out, priority); | printMessage(msg, out, priority); | ||||
| @@ -321,8 +321,7 @@ public abstract class AbstractCvsTask extends Task { | |||||
| try { | try { | ||||
| String actualCommandLine = executeToString(exe); | String actualCommandLine = executeToString(exe); | ||||
| log("running cvs command: " + actualCommandLine, | |||||
| Project.MSG_DEBUG); | |||||
| log(actualCommandLine, Project.MSG_VERBOSE); | |||||
| int retCode = exe.execute(); | int retCode = exe.execute(); | ||||
| log("retCode=" + retCode, Project.MSG_DEBUG); | log("retCode=" + retCode, Project.MSG_DEBUG); | ||||
| /*Throw an exception if cvs exited with error. (Iulian)*/ | /*Throw an exception if cvs exited with error. (Iulian)*/ | ||||
| @@ -400,13 +399,9 @@ public abstract class AbstractCvsTask extends Task { | |||||
| private String executeToString(Execute execute){ | private String executeToString(Execute execute){ | ||||
| StringBuffer stringBuffer = new StringBuffer(250); | |||||
| String[] commandLine = execute.getCommandline(); | |||||
| for (int i = 0; i < commandLine.length; i++){ | |||||
| stringBuffer.append(commandLine[i]); | |||||
| stringBuffer.append(" "); | |||||
| } | |||||
| StringBuffer stringBuffer = | |||||
| new StringBuffer(Commandline.describeCommand(execute | |||||
| .getCommandline())); | |||||
| String newLine = StringUtils.LINE_SEP; | String newLine = StringUtils.LINE_SEP; | ||||
| String[] variableArray = execute.getEnvironment(); | String[] variableArray = execute.getEnvironment(); | ||||
| @@ -303,9 +303,6 @@ public class ExecTask extends Task { | |||||
| if (dir == null) { | if (dir == null) { | ||||
| dir = project.getBaseDir(); | dir = project.getBaseDir(); | ||||
| } | } | ||||
| // show the command | |||||
| log(cmdl.toString(), Project.MSG_VERBOSE); | |||||
| Execute exe = new Execute(createHandler(), createWatchdog()); | Execute exe = new Execute(createHandler(), createWatchdog()); | ||||
| exe.setAntRun(getProject()); | exe.setAntRun(getProject()); | ||||
| exe.setWorkingDirectory(dir); | exe.setWorkingDirectory(dir); | ||||
| @@ -363,6 +360,9 @@ public class ExecTask extends Task { | |||||
| * overidden by subclasses | * overidden by subclasses | ||||
| */ | */ | ||||
| protected void runExec(Execute exe) throws BuildException { | protected void runExec(Execute exe) throws BuildException { | ||||
| // show the command | |||||
| log(cmdl.describeCommand(), Project.MSG_VERBOSE); | |||||
| exe.setCommandline(cmdl.getCommandline()); | exe.setCommandline(cmdl.getCommandline()); | ||||
| try { | try { | ||||
| runExecute(exe); | runExecute(exe); | ||||
| @@ -63,7 +63,6 @@ import org.apache.tools.ant.taskdefs.condition.Os; | |||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.BufferedReader; | import java.io.BufferedReader; | ||||
| import java.io.StringReader; | import java.io.StringReader; | ||||
| import java.io.ByteArrayOutputStream; | import java.io.ByteArrayOutputStream; | ||||
| @@ -507,7 +506,8 @@ public class Execute { | |||||
| public static void runCommand(Task task, String[] cmdline) | public static void runCommand(Task task, String[] cmdline) | ||||
| throws BuildException { | throws BuildException { | ||||
| try { | try { | ||||
| task.log(Commandline.toString(cmdline), Project.MSG_VERBOSE); | |||||
| task.log(Commandline.describeCommand(cmdline), | |||||
| Project.MSG_VERBOSE); | |||||
| Execute exe = new Execute(new LogStreamHandler(task, | Execute exe = new Execute(new LogStreamHandler(task, | ||||
| Project.MSG_INFO, | Project.MSG_INFO, | ||||
| Project.MSG_ERR)); | Project.MSG_ERR)); | ||||
| @@ -542,7 +542,8 @@ public class Execute { | |||||
| throws IOException { | throws IOException { | ||||
| if (project != null) { | if (project != null) { | ||||
| project.log("Execute:CommandLauncher: " + | project.log("Execute:CommandLauncher: " + | ||||
| Commandline.toString(cmd), Project.MSG_DEBUG); | |||||
| Commandline.describeCommand(cmd), | |||||
| Project.MSG_DEBUG); | |||||
| } | } | ||||
| return Runtime.getRuntime().exec(cmd, env); | return Runtime.getRuntime().exec(cmd, env); | ||||
| } | } | ||||
| @@ -588,7 +589,8 @@ public class Execute { | |||||
| } | } | ||||
| if (project != null) { | if (project != null) { | ||||
| project.log("Execute:Java11CommandLauncher: " + | project.log("Execute:Java11CommandLauncher: " + | ||||
| Commandline.toString(newcmd), Project.MSG_DEBUG); | |||||
| Commandline.describeCommand(newcmd), | |||||
| Project.MSG_DEBUG); | |||||
| } | } | ||||
| return Runtime.getRuntime().exec(newcmd, env); | return Runtime.getRuntime().exec(newcmd, env); | ||||
| } | } | ||||
| @@ -615,7 +617,8 @@ public class Execute { | |||||
| try { | try { | ||||
| if (project != null) { | if (project != null) { | ||||
| project.log("Execute:Java13CommandLauncher: " + | project.log("Execute:Java13CommandLauncher: " + | ||||
| Commandline.toString(cmd), Project.MSG_DEBUG); | |||||
| Commandline.describeCommand(cmd), | |||||
| Project.MSG_DEBUG); | |||||
| } | } | ||||
| Object[] arguments = { cmd, env, workingDir }; | Object[] arguments = { cmd, env, workingDir }; | ||||
| return (Process) _execWithCWD.invoke(Runtime.getRuntime(), | return (Process) _execWithCWD.invoke(Runtime.getRuntime(), | ||||
| @@ -240,7 +240,7 @@ public class ExecuteOn extends ExecTask { | |||||
| fileNames.copyInto(s); | fileNames.copyInto(s); | ||||
| for (int j = 0; j < s.length; j++) { | for (int j = 0; j < s.length; j++) { | ||||
| String[] command = getCommandline(s[j], base); | String[] command = getCommandline(s[j], base); | ||||
| log("Executing " + Commandline.toString(command), | |||||
| log(Commandline.describeCommand(command), | |||||
| Project.MSG_VERBOSE); | Project.MSG_VERBOSE); | ||||
| exe.setCommandline(command); | exe.setCommandline(command); | ||||
| runExecute(exe); | runExecute(exe); | ||||
| @@ -256,8 +256,7 @@ public class ExecuteOn extends ExecTask { | |||||
| File[] b = new File[baseDirs.size()]; | File[] b = new File[baseDirs.size()]; | ||||
| baseDirs.copyInto(b); | baseDirs.copyInto(b); | ||||
| String[] command = getCommandline(s, b); | String[] command = getCommandline(s, b); | ||||
| log("Executing " + Commandline.toString(command), | |||||
| Project.MSG_VERBOSE); | |||||
| log(Commandline.describeCommand(command), Project.MSG_VERBOSE); | |||||
| exe.setCommandline(command); | exe.setCommandline(command); | ||||
| runExecute(exe); | runExecute(exe); | ||||
| } | } | ||||
| @@ -135,7 +135,7 @@ public class Java extends Task { | |||||
| } | } | ||||
| if (fork) { | if (fork) { | ||||
| log("Forking " + cmdl.toString(), Project.MSG_VERBOSE); | |||||
| log(cmdl.describeCommand(), Project.MSG_VERBOSE); | |||||
| } else { | } else { | ||||
| if (cmdl.getVmCommand().size() > 1) { | if (cmdl.getVmCommand().size() > 1) { | ||||
| log("JVM args ignored when same JVM is used.", | log("JVM args ignored when same JVM is used.", | ||||
| @@ -151,7 +151,7 @@ public class Java extends Task { | |||||
| + "JVM is used.", Project.MSG_WARN); | + "JVM is used.", Project.MSG_WARN); | ||||
| } | } | ||||
| log("Running in same VM " + cmdl.getJavaCommand().toString(), | |||||
| log("Running in same VM " + cmdl.describeJavaCommand(), | |||||
| Project.MSG_VERBOSE); | Project.MSG_VERBOSE); | ||||
| } | } | ||||
| @@ -1687,7 +1687,7 @@ public class Javadoc extends Task { | |||||
| if (packageList != null) { | if (packageList != null) { | ||||
| toExecute.createArgument().setValue("@" + packageList); | toExecute.createArgument().setValue("@" + packageList); | ||||
| } | } | ||||
| log("Javadoc args: " + toExecute, Project.MSG_VERBOSE); | |||||
| log(toExecute.describeCommand(), Project.MSG_VERBOSE); | |||||
| log("Javadoc execution", Project.MSG_INFO); | log("Javadoc execution", Project.MSG_INFO); | ||||
| @@ -374,8 +374,8 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter { | |||||
| * &qout;niceSourceList" | * &qout;niceSourceList" | ||||
| */ | */ | ||||
| protected void logAndAddFilesToCompile(Commandline cmd) { | protected void logAndAddFilesToCompile(Commandline cmd) { | ||||
| attributes.log("Compilation args: " + cmd.toString(), | |||||
| Project.MSG_VERBOSE); | |||||
| attributes.log("Compilation " + cmd.describeArguments(), | |||||
| Project.MSG_VERBOSE); | |||||
| StringBuffer niceSourceList = new StringBuffer("File"); | StringBuffer niceSourceList = new StringBuffer("File"); | ||||
| if (compileList.length != 1) { | if (compileList.length != 1) { | ||||
| @@ -1,7 +1,7 @@ | |||||
| /* | /* | ||||
| * The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
| * | * | ||||
| * Copyright (c) 2000-2001 The Apache Software Foundation. All rights | |||||
| * Copyright (c) 2000-2002 The Apache Software Foundation. All rights | |||||
| * reserved. | * reserved. | ||||
| * | * | ||||
| * Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
| @@ -188,7 +188,7 @@ public class ANTLR extends Task { | |||||
| commandline.createArgument().setValue(outputDirectory.toString()); | commandline.createArgument().setValue(outputDirectory.toString()); | ||||
| commandline.createArgument().setValue(target.toString()); | commandline.createArgument().setValue(target.toString()); | ||||
| log("Forking " + commandline.toString(), Project.MSG_VERBOSE); | |||||
| log(commandline.describeCommand(), Project.MSG_VERBOSE); | |||||
| int err = run(commandline.getCommandline()); | int err = run(commandline.getCommandline()); | ||||
| if (err == 1) { | if (err == 1) { | ||||
| throw new BuildException("ANTLR returned: " + err, location); | throw new BuildException("ANTLR returned: " + err, location); | ||||
| @@ -390,7 +390,7 @@ public class Javah extends Task { | |||||
| */ | */ | ||||
| protected void logAndAddFilesToCompile(Commandline cmd) { | protected void logAndAddFilesToCompile(Commandline cmd) { | ||||
| int n = 0; | int n = 0; | ||||
| log("Compilation args: " + cmd.toString(), | |||||
| log("Compilation " + cmd.describeArguments(), | |||||
| Project.MSG_VERBOSE); | Project.MSG_VERBOSE); | ||||
| StringBuffer niceClassList = new StringBuffer(); | StringBuffer niceClassList = new StringBuffer(); | ||||
| @@ -171,7 +171,7 @@ public class Rpm extends Task { | |||||
| exe.setAntRun(project); | exe.setAntRun(project); | ||||
| if (topDir == null) { | if (topDir == null) { | ||||
| topDir = project.getBaseDir(); | |||||
| topDir = project.getBaseDir(); | |||||
| } | } | ||||
| exe.setWorkingDirectory(topDir); | exe.setWorkingDirectory(topDir); | ||||
| @@ -119,7 +119,7 @@ public class CCMCreateTask extends Continuus implements ExecuteStreamHandler { | |||||
| commandLine2.createArgument().setValue(COMMAND_DEFAULT_TASK); | commandLine2.createArgument().setValue(COMMAND_DEFAULT_TASK); | ||||
| commandLine2.createArgument().setValue(getTask()); | commandLine2.createArgument().setValue(getTask()); | ||||
| log(commandLine.toString(), Project.MSG_DEBUG); | |||||
| log(commandLine.describeCommand(), Project.MSG_DEBUG); | |||||
| result = run(commandLine2); | result = run(commandLine2); | ||||
| if (result != 0) { | if (result != 0) { | ||||
| @@ -323,31 +323,31 @@ public class CCUpdate extends ClearCase { | |||||
| } | } | ||||
| } | } | ||||
| /** | |||||
| /** | |||||
| * -graphical flag -- display graphical dialog during update operation | * -graphical flag -- display graphical dialog during update operation | ||||
| */ | */ | ||||
| public static final String FLAG_GRAPHICAL = "-graphical"; | public static final String FLAG_GRAPHICAL = "-graphical"; | ||||
| /** | |||||
| /** | |||||
| * -log flag -- file to log status to | * -log flag -- file to log status to | ||||
| */ | */ | ||||
| public static final String FLAG_LOG = "-log"; | public static final String FLAG_LOG = "-log"; | ||||
| /** | |||||
| /** | |||||
| * -overwrite flag -- overwrite hijacked files | * -overwrite flag -- overwrite hijacked files | ||||
| */ | */ | ||||
| public static final String FLAG_OVERWRITE = "-overwrite"; | public static final String FLAG_OVERWRITE = "-overwrite"; | ||||
| /** | |||||
| /** | |||||
| * -noverwrite flag -- do not overwrite hijacked files | * -noverwrite flag -- do not overwrite hijacked files | ||||
| */ | */ | ||||
| public static final String FLAG_NOVERWRITE = "-noverwrite"; | public static final String FLAG_NOVERWRITE = "-noverwrite"; | ||||
| /** | |||||
| /** | |||||
| * -rename flag -- rename hijacked files with .keep extension | * -rename flag -- rename hijacked files with .keep extension | ||||
| */ | */ | ||||
| public static final String FLAG_RENAME = "-rename"; | public static final String FLAG_RENAME = "-rename"; | ||||
| /** | |||||
| /** | |||||
| * -ctime flag -- modified time is written as the current time | * -ctime flag -- modified time is written as the current time | ||||
| */ | */ | ||||
| public static final String FLAG_CURRENTTIME = "-ctime"; | public static final String FLAG_CURRENTTIME = "-ctime"; | ||||
| /** | |||||
| /** | |||||
| * -ptime flag -- modified time is written as the VOB time | * -ptime flag -- modified time is written as the VOB time | ||||
| */ | */ | ||||
| public static final String FLAG_PRESERVETIME = "-ptime"; | public static final String FLAG_PRESERVETIME = "-ptime"; | ||||
| @@ -242,10 +242,10 @@ public class NetCommand { | |||||
| // assume the worst | // assume the worst | ||||
| try { | try { | ||||
| if (traceCommandLine) { | if (traceCommandLine) { | ||||
| owner.log(commandLine.toString()); | |||||
| owner.log(commandLine.describeCommand()); | |||||
| } else { | } else { | ||||
| //in verbose mode we always log stuff | //in verbose mode we always log stuff | ||||
| logVerbose(commandLine.toString()); | |||||
| logVerbose(commandLine.describeCommand()); | |||||
| } | } | ||||
| executable.setCommandline(commandLine.getCommandline()); | executable.setCommandline(commandLine.getCommandline()); | ||||
| err = executable.execute(); | err = executable.execute(); | ||||
| @@ -351,7 +351,7 @@ public class BorlandDeploymentTool extends GenericDeploymentTool implements Exe | |||||
| try { | try { | ||||
| log("Calling java2iiop", Project.MSG_VERBOSE); | log("Calling java2iiop", Project.MSG_VERBOSE); | ||||
| log(commandline.toString(), Project.MSG_DEBUG); | |||||
| log(commandline.describeCommand(), Project.MSG_DEBUG); | |||||
| execTask.setCommandline(commandline.getCommandline()); | execTask.setCommandline(commandline.getCommandline()); | ||||
| int result = execTask.execute(); | int result = execTask.execute(); | ||||
| if (result != 0) { | if (result != 0) { | ||||
| @@ -212,7 +212,7 @@ public class JJTree extends Task { | |||||
| Project.MSG_INFO, | Project.MSG_INFO, | ||||
| Project.MSG_INFO), | Project.MSG_INFO), | ||||
| null); | null); | ||||
| log(cmdl.toString(), Project.MSG_VERBOSE); | |||||
| log(cmdl.describeCommand(), Project.MSG_VERBOSE); | |||||
| process.setCommandline(cmdl.getCommandline()); | process.setCommandline(cmdl.getCommandline()); | ||||
| try { | try { | ||||
| @@ -410,7 +410,7 @@ public class JDependTask extends Task { | |||||
| if (getOutputFile() != null) { | if (getOutputFile() != null) { | ||||
| log("Output to be stored in " + getOutputFile().getPath()); | log("Output to be stored in " + getOutputFile().getPath()); | ||||
| } | } | ||||
| log("Executing: " + commandline.toString(), Project.MSG_VERBOSE); | |||||
| log(commandline.describeCommand(), Project.MSG_VERBOSE); | |||||
| try { | try { | ||||
| return execute.execute(); | return execute.execute(); | ||||
| } catch (IOException e) { | } catch (IOException e) { | ||||
| @@ -84,7 +84,8 @@ public abstract class DefaultJspCompilerAdapter | |||||
| protected void logAndAddFilesToCompile(JspC jspc, | protected void logAndAddFilesToCompile(JspC jspc, | ||||
| Vector compileList, | Vector compileList, | ||||
| Commandline cmd) { | Commandline cmd) { | ||||
| jspc.log("Compilation args: " + cmd.toString(), Project.MSG_VERBOSE); | |||||
| jspc.log("Compilation " + cmd.describeArguments(), | |||||
| Project.MSG_VERBOSE); | |||||
| StringBuffer niceSourceList = new StringBuffer("File"); | StringBuffer niceSourceList = new StringBuffer("File"); | ||||
| if (compileList.size() != 1) { | if (compileList.size() != 1) { | ||||
| @@ -667,7 +667,7 @@ public class JUnitTask extends Task { | |||||
| execute.setNewenvironment(newEnvironment); | execute.setNewenvironment(newEnvironment); | ||||
| execute.setEnvironment(environment); | execute.setEnvironment(environment); | ||||
| log("Executing: " + cmd.toString(), Project.MSG_VERBOSE); | |||||
| log(cmd.describeCommand(), Project.MSG_VERBOSE); | |||||
| int retVal; | int retVal; | ||||
| try { | try { | ||||
| retVal = execute.execute(); | retVal = execute.execute(); | ||||
| @@ -212,7 +212,7 @@ public abstract class AbstractMetamataTask extends Task { | |||||
| /** execute the process with a specific handler */ | /** execute the process with a specific handler */ | ||||
| protected void execute0(ExecuteStreamHandler handler) throws BuildException { | protected void execute0(ExecuteStreamHandler handler) throws BuildException { | ||||
| final Execute process = new Execute(handler); | final Execute process = new Execute(handler); | ||||
| log(cmdl.toString(), Project.MSG_VERBOSE); | |||||
| log(cmdl.describeCommand(), Project.MSG_VERBOSE); | |||||
| process.setCommandline(cmdl.getCommandline()); | process.setCommandline(cmdl.getCommandline()); | ||||
| try { | try { | ||||
| if (process.execute() != 0) { | if (process.execute() != 0) { | ||||
| @@ -212,7 +212,7 @@ public class MParse extends Task { | |||||
| } | } | ||||
| final Execute process = new Execute(handler); | final Execute process = new Execute(handler); | ||||
| log(cmdl.toString(), Project.MSG_VERBOSE); | |||||
| log(cmdl.describeCommand(), Project.MSG_VERBOSE); | |||||
| process.setCommandline(cmdl.getCommandline()); | process.setCommandline(cmdl.getCommandline()); | ||||
| try { | try { | ||||
| if (process.execute() != 0) { | if (process.execute() != 0) { | ||||
| @@ -188,7 +188,7 @@ public abstract class P4Base extends org.apache.tools.ant.Task { | |||||
| cmdl += cmdline[i] + " "; | cmdl += cmdline[i] + " "; | ||||
| } | } | ||||
| log("Execing " + cmdl, Project.MSG_VERBOSE); | |||||
| log(cmdl.describeCommand(), Project.MSG_VERBOSE); | |||||
| if (handler == null) { | if (handler == null) { | ||||
| handler = new SimpleP4OutputHandler(this); | handler = new SimpleP4OutputHandler(this); | ||||
| @@ -208,7 +208,7 @@ public class Pvcs extends org.apache.tools.ant.Task { | |||||
| Random rand = new Random(System.currentTimeMillis()); | Random rand = new Random(System.currentTimeMillis()); | ||||
| tmp = new File("pvcs_ant_" + rand.nextLong() + ".log"); | tmp = new File("pvcs_ant_" + rand.nextLong() + ".log"); | ||||
| tmp2 = new File("pvcs_ant_" + rand.nextLong() + ".log"); | tmp2 = new File("pvcs_ant_" + rand.nextLong() + ".log"); | ||||
| log("Executing " + commandLine.toString(), Project.MSG_VERBOSE); | |||||
| log(commandLine.describeCommand(), Project.MSG_VERBOSE); | |||||
| result = runCmd(commandLine, | result = runCmd(commandLine, | ||||
| new PumpStreamHandler(new FileOutputStream(tmp), | new PumpStreamHandler(new FileOutputStream(tmp), | ||||
| new LogOutputStream(this, Project.MSG_WARN))); | new LogOutputStream(this, Project.MSG_WARN))); | ||||
| @@ -135,7 +135,7 @@ public class CovMerge extends Task { | |||||
| LogStreamHandler handler = new LogStreamHandler(this, Project.MSG_INFO, Project.MSG_WARN); | LogStreamHandler handler = new LogStreamHandler(this, Project.MSG_INFO, Project.MSG_WARN); | ||||
| Execute exec = new Execute(handler); | Execute exec = new Execute(handler); | ||||
| log(cmdl.toString(), Project.MSG_VERBOSE); | |||||
| log(cmdl.describeCommand(), Project.MSG_VERBOSE); | |||||
| exec.setCommandline(cmdl.getCommandline()); | exec.setCommandline(cmdl.getCommandline()); | ||||
| // JProbe process always return 0 so we will not be | // JProbe process always return 0 so we will not be | ||||
| @@ -285,7 +285,7 @@ public class CovReport extends Task { | |||||
| // use the custom handler for stdin issues | // use the custom handler for stdin issues | ||||
| LogStreamHandler handler = new LogStreamHandler(this, Project.MSG_INFO, Project.MSG_WARN); | LogStreamHandler handler = new LogStreamHandler(this, Project.MSG_INFO, Project.MSG_WARN); | ||||
| Execute exec = new Execute(handler); | Execute exec = new Execute(handler); | ||||
| log(cmdl.toString(), Project.MSG_VERBOSE); | |||||
| log(cmdl.describeCommand(), Project.MSG_VERBOSE); | |||||
| exec.setCommandline(cmdl.getCommandline()); | exec.setCommandline(cmdl.getCommandline()); | ||||
| int exitValue = exec.execute(); | int exitValue = exec.execute(); | ||||
| if (exitValue != 0) { | if (exitValue != 0) { | ||||
| @@ -277,7 +277,7 @@ public class Coverage extends Task { | |||||
| // use the custom handler for stdin issues | // use the custom handler for stdin issues | ||||
| LogStreamHandler handler = new CoverageStreamHandler(this); | LogStreamHandler handler = new CoverageStreamHandler(this); | ||||
| Execute exec = new Execute(handler); | Execute exec = new Execute(handler); | ||||
| log(cmdl.toString(), Project.MSG_VERBOSE); | |||||
| log(cmdl.describeCommand(), Project.MSG_VERBOSE); | |||||
| exec.setCommandline(cmdl.getCommandline()); | exec.setCommandline(cmdl.getCommandline()); | ||||
| int exitValue = exec.execute(); | int exitValue = exec.execute(); | ||||
| if (exitValue != 0) { | if (exitValue != 0) { | ||||
| @@ -260,7 +260,7 @@ public abstract class DefaultRmicAdapter implements RmicAdapter { | |||||
| protected void logAndAddFilesToCompile(Commandline cmd) { | protected void logAndAddFilesToCompile(Commandline cmd) { | ||||
| Vector compileList = attributes.getCompileList(); | Vector compileList = attributes.getCompileList(); | ||||
| attributes.log("Compilation args: " + cmd.toString(), | |||||
| attributes.log("Compilation " + cmd.describeArguments(), | |||||
| Project.MSG_VERBOSE); | Project.MSG_VERBOSE); | ||||
| StringBuffer niceSourceList = new StringBuffer("File"); | StringBuffer niceSourceList = new StringBuffer("File"); | ||||
| @@ -55,6 +55,7 @@ | |||||
| package org.apache.tools.ant.types; | package org.apache.tools.ant.types; | ||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| import org.apache.tools.ant.util.StringUtils; | |||||
| import java.io.File; | import java.io.File; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import java.util.StringTokenizer; | import java.util.StringTokenizer; | ||||
| @@ -87,6 +88,13 @@ public class Commandline implements Cloneable { | |||||
| private Vector arguments = new Vector(); | private Vector arguments = new Vector(); | ||||
| private String executable = null; | private String executable = null; | ||||
| protected static final String DISCLAIMER = | |||||
| StringUtils.LINE_SEP | |||||
| + "The \' characters around the executable and arguments are" | |||||
| + StringUtils.LINE_SEP | |||||
| + "not part of the command." | |||||
| + StringUtils.LINE_SEP; | |||||
| public Commandline(String to_process) { | public Commandline(String to_process) { | ||||
| super(); | super(); | ||||
| String[] tmp = translateCommandline(to_process); | String[] tmp = translateCommandline(to_process); | ||||
| @@ -230,7 +238,7 @@ public class Commandline implements Cloneable { | |||||
| */ | */ | ||||
| public void setExecutable(String executable) { | public void setExecutable(String executable) { | ||||
| if (executable == null || executable.length() == 0) { | if (executable == null || executable.length() == 0) { | ||||
| return; | |||||
| return; | |||||
| } | } | ||||
| this.executable = executable.replace('/', File.separatorChar) | this.executable = executable.replace('/', File.separatorChar) | ||||
| .replace('\\', File.separatorChar); | .replace('\\', File.separatorChar); | ||||
| @@ -254,7 +262,7 @@ public class Commandline implements Cloneable { | |||||
| public String[] getCommandline() { | public String[] getCommandline() { | ||||
| final String[] args = getArguments(); | final String[] args = getArguments(); | ||||
| if (executable == null) { | if (executable == null) { | ||||
| return args; | |||||
| return args; | |||||
| } | } | ||||
| final String[] result = new String[args.length + 1]; | final String[] result = new String[args.length + 1]; | ||||
| result[0] = executable; | result[0] = executable; | ||||
| @@ -313,10 +321,14 @@ public class Commandline implements Cloneable { | |||||
| } | } | ||||
| } | } | ||||
| /** | |||||
| * Quotes the parts of the given array in way that makes them | |||||
| * usable as command line arguments. | |||||
| */ | |||||
| public static String toString(String [] line) { | public static String toString(String [] line) { | ||||
| // empty path return empty string | // empty path return empty string | ||||
| if (line == null || line.length == 0) { | if (line == null || line.length == 0) { | ||||
| return ""; | |||||
| return ""; | |||||
| } | } | ||||
| // path containing one or more elements | // path containing one or more elements | ||||
| @@ -411,7 +423,8 @@ public class Commandline implements Cloneable { | |||||
| } | } | ||||
| /** | /** | ||||
| * Clear out the arguments but leave the executable in place for another operation. | |||||
| * Clear out the arguments but leave the executable in place for | |||||
| * another operation. | |||||
| */ | */ | ||||
| public void clearArgs() { | public void clearArgs() { | ||||
| arguments.removeAllElements(); | arguments.removeAllElements(); | ||||
| @@ -428,4 +441,112 @@ public class Commandline implements Cloneable { | |||||
| return new Marker(arguments.size()); | return new Marker(arguments.size()); | ||||
| } | } | ||||
| /** | |||||
| * Returns a String that describes the command and arguments | |||||
| * suitable for verbose output before a call to | |||||
| * <code>Runtime.exec(String[])<code> | |||||
| * | |||||
| * @since Ant 1.5 | |||||
| */ | |||||
| public String describeCommand() { | |||||
| return describeCommand(this); | |||||
| } | |||||
| /** | |||||
| * Returns a String that describes the arguments suitable for | |||||
| * verbose output before a call to | |||||
| * <code>Runtime.exec(String[])<code> | |||||
| * | |||||
| * @since Ant 1.5 | |||||
| */ | |||||
| public String describeArguments() { | |||||
| return describeArguments(this); | |||||
| } | |||||
| /** | |||||
| * Returns a String that describes the command and arguments | |||||
| * suitable for verbose output before a call to | |||||
| * <code>Runtime.exec(String[])<code> | |||||
| * | |||||
| * @since Ant 1.5 | |||||
| */ | |||||
| public static String describeCommand(Commandline line) { | |||||
| return describeCommand(line.getCommandline()); | |||||
| } | |||||
| /** | |||||
| * Returns a String that describes the arguments suitable for | |||||
| * verbose output before a call to | |||||
| * <code>Runtime.exec(String[])<code> | |||||
| * | |||||
| * @since Ant 1.5 | |||||
| */ | |||||
| public static String describeArguments(Commandline line) { | |||||
| return describeArguments(line.getArguments()); | |||||
| } | |||||
| /** | |||||
| * Returns a String that describes the command and arguments | |||||
| * suitable for verbose output before a call to | |||||
| * <code>Runtime.exec(String[])<code> | |||||
| * | |||||
| * <p>This method assumes that the first entry in the array is the | |||||
| * executable to run.</p> | |||||
| * | |||||
| * @since Ant 1.5 | |||||
| */ | |||||
| public static String describeCommand(String[] args) { | |||||
| if (args == null || args.length == 0) { | |||||
| return ""; | |||||
| } | |||||
| StringBuffer buf = new StringBuffer("Executing \'"); | |||||
| buf.append(args[0]); | |||||
| buf.append("\'"); | |||||
| if (args.length > 0) { | |||||
| buf.append(" with "); | |||||
| buf.append(describeArguments(args, 1)); | |||||
| } else { | |||||
| buf.append(DISCLAIMER); | |||||
| } | |||||
| return buf.toString(); | |||||
| } | |||||
| /** | |||||
| * Returns a String that describes the arguments suitable for | |||||
| * verbose output before a call to | |||||
| * <code>Runtime.exec(String[])<code> | |||||
| * | |||||
| * @since Ant 1.5 | |||||
| */ | |||||
| public static String describeArguments(String[] args) { | |||||
| return describeArguments(args, 0); | |||||
| } | |||||
| /** | |||||
| * Returns a String that describes the arguments suitable for | |||||
| * verbose output before a call to | |||||
| * <code>Runtime.exec(String[])<code> | |||||
| * | |||||
| * @param offset ignore entries before this index | |||||
| * | |||||
| * @since Ant 1.5 | |||||
| */ | |||||
| protected static String describeArguments(String[] args, int offset) { | |||||
| if (args == null || args.length <= offset) { | |||||
| return ""; | |||||
| } | |||||
| StringBuffer buf = new StringBuffer("argument"); | |||||
| if (args.length > offset) { | |||||
| buf.append("s"); | |||||
| } | |||||
| buf.append(":").append(StringUtils.LINE_SEP); | |||||
| for (int i = offset; i < args.length; i++) { | |||||
| buf.append("\'").append(args[i]).append("\'") | |||||
| .append(StringUtils.LINE_SEP); | |||||
| } | |||||
| buf.append(DISCLAIMER); | |||||
| return buf.toString(); | |||||
| } | |||||
| } | } | ||||
| @@ -283,6 +283,29 @@ public class CommandlineJava implements Cloneable { | |||||
| return Commandline.toString(getCommandline()); | return Commandline.toString(getCommandline()); | ||||
| } | } | ||||
| /** | |||||
| * Returns a String that describes the command and arguments | |||||
| * suitable for verbose output before a call to | |||||
| * <code>Runtime.exec(String[])<code> | |||||
| * | |||||
| * @since Ant 1.5 | |||||
| */ | |||||
| public String describeCommand() { | |||||
| return Commandline.describeCommand(getCommandline()); | |||||
| } | |||||
| /** | |||||
| * Returns a String that describes the java command and arguments | |||||
| * for in VM executions. | |||||
| * | |||||
| * <p>The class name is the executable in this context.</p> | |||||
| * | |||||
| * @since Ant 1.5 | |||||
| */ | |||||
| public String describeJavaCommand() { | |||||
| return Commandline.describeCommand(getJavaCommand()); | |||||
| } | |||||
| private Commandline getActualVMCommand() { | private Commandline getActualVMCommand() { | ||||
| Commandline actualVMCommand = (Commandline) vmCommand.clone(); | Commandline actualVMCommand = (Commandline) vmCommand.clone(); | ||||
| if (maxMemory != null) { | if (maxMemory != null) { | ||||