diff --git a/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java b/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java index 56863c23c..67e918232 100644 --- a/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java +++ b/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java @@ -64,7 +64,7 @@ import java.io.IOException; /** * Executes a given command, supplying a set of files as arguments. * - * @author Stefan Bodewig + * @author Stefan Bodewig * @author Mariusz Nowostawski */ public class ExecuteOn extends ExecTask { @@ -72,6 +72,7 @@ public class ExecuteOn extends ExecTask { protected Vector filesets = new Vector(); private boolean parallel = false; protected String type = "file"; + protected Commandline.Marker srcFilePos = null; /** * Adds a set of files (nested fileset attribute). @@ -94,6 +95,19 @@ public class ExecuteOn extends ExecTask { this.type = type.getValue(); } + /** + * Marker that indicates where the name of the source file should + * be put on the command line. + */ + public Commandline.Marker createSrcfile() { + if (srcFilePos != null) { + throw new BuildException(taskType + " doesn\'t support multiple srcfile elements.", + location); + } + srcFilePos = cmdl.createMarker(); + return srcFilePos; + } + protected void checkConfiguration() { super.checkConfiguration(); if (filesets.size() == 0) { @@ -128,11 +142,11 @@ public class ExecuteOn extends ExecTask { v.copyInto(s); int err = -1; - String myos = System.getProperty("os.name"); if (parallel) { - cmdl.addArguments(s); - exe.setCommandline(cmdl.getCommandline()); + String[] command = getCommandline(s); + log("Executing " + Commandline.toString(command), Project.MSG_VERBOSE); + exe.setCommandline(command); err = exe.execute(); if (err != 0) { if (failOnError) { @@ -144,11 +158,10 @@ public class ExecuteOn extends ExecTask { } } else { - String[] cmd = new String[cmdl.size()+1]; - System.arraycopy(cmdl.getCommandline(), 0, cmd, 0, cmdl.size()); for (int i=0; iThis class is there to support the srcfile and targetfile + // elements of <execon> and <transform> - don't know + // whether there might be additional use cases.

--SB + public class Marker { + + private int position; + private int realPos = -1; + + Marker(int position) { + this.position = position; + } + + /** + * Return the number of arguments that preceeded this marker. + * + *

The name of the executable - if set - is counted as the + * very first argument.

+ */ + public int getPosition() { + if (realPos == -1) { + realPos = (executable == null ? 0 : 1); + for (int i=0; iThis marker can be used to locate a position on the + * commandline - to insert something for example - when all + * parameters have been set.

+ */ + public Marker createMarker() { + return new Marker(arguments.size()); + } }