![]() |
|
|
|
#1 |
|
I am trying to use <exec> tag in ant to call an native executable. When
I use the command: "ant dir", I got following errors: (I just want to learn how to use exec task ). can anyone tell me what happened? <project> <target name="dir"> <exec executable ="copy"> <arg value="build.xml"/> <arg value="build.xml.bbb"/> </exec> </target> </project> ------------errors---------- Complete build sequence is [dir, ] dir: [exec] Current OS is Windows XP [exec] Executing 'copy' with arguments: [exec] 'build.xml' [exec] 'build.xml.bbb' [exec] [exec] The ' characters around the executable and arguments are [exec] not part of the command. BUILD FAILED C:\jtest\build.xml:3: Execute failed: java.io.IOException: CreateProcess: copy b uild.xml build.xml.bbb error=2 at org.apache.tools.ant.taskdefs.ExecTask.runExec(Exe cTask.java:620) at org.apache.tools.ant.taskdefs.ExecTask.execute(Exe cTask.java:452) at org.apache.tools.ant.UnknownElement.execute(Unknow nElement.java:275) at org.apache.tools.ant.Task.perform(Task.java:364) at org.apache.tools.ant.Target.execute(Target.java:34 1) at org.apache.tools.ant.Target.performTasks(Target.ja va:369) at org.apache.tools.ant.Project.executeSortedTargets( Project.java:1216) at org.apache.tools.ant.Project.executeTarget(Project .java:1185) at org.apache.tools.ant.helper.DefaultExecutor.execut eTargets(DefaultExe david wolf |
|
|
|
|
#2 |
|
Posts: n/a
|
david wolf wrote:
> I am trying to use <exec> tag in ant to call an native executable. When > I use the command: > "ant dir", I got following errors: (I just want to learn how to use > exec task ). can anyone tell me what happened? > > <project> > <target name="dir"> > <exec executable ="copy"> > <arg value="build.xml"/> > <arg value="build.xml.bbb"/> > </exec> > </target> > > </project> > > ------------errors---------- > > Complete build sequence is [dir, ] > > dir: > [exec] Current OS is Windows XP > [exec] Executing 'copy' with arguments: > [exec] 'build.xml' > [exec] 'build.xml.bbb' > [exec] > [exec] The ' characters around the executable and arguments are > [exec] not part of the command. > > BUILD FAILED > C:\jtest\build.xml:3: Execute failed: java.io.IOException: > CreateProcess: copy b > uild.xml build.xml.bbb error=2 > at > org.apache.tools.ant.taskdefs.ExecTask.runExec(Exe cTask.java:620) > at > org.apache.tools.ant.taskdefs.ExecTask.execute(Exe cTask.java:452) > at > org.apache.tools.ant.UnknownElement.execute(Unknow nElement.java:275) > at org.apache.tools.ant.Task.perform(Task.java:364) > at org.apache.tools.ant.Target.execute(Target.java:34 1) > at org.apache.tools.ant.Target.performTasks(Target.ja va:369) > at > org.apache.tools.ant.Project.executeSortedTargets( Project.java:1216) > at > org.apache.tools.ant.Project.executeTarget(Project .java:1185) > at > org.apache.tools.ant.helper.DefaultExecutor.execut eTargets(DefaultExe > Why aren't you using the copy task? http://ant.apache.org/manual/CoreTasks/copy.html -- Tony Morris http://tmorris.net/ s/Commonwealth Games/Commonwealth Swimming Tony Morris |
|
|
|
#3 |
|
Posts: n/a
|
On Sat, 2006-04-01 at 09:57 +1000, Tony Morris wrote:
> Why aren't you using the copy task? > http://ant.apache.org/manual/CoreTasks/copy.html The OP said "I just want to learn how to use exec task" Under a real OS shell, this works fine: <target name="test"> <exec executable="cp"> <arg value="/tmp/foo"/> <arg value="/tmp/bar"/> </exec> </target> James McGill |
|
|
|
#4 |
|
Posts: n/a
|
James McGill wrote:
> On Sat, 2006-04-01 at 09:57 +1000, Tony Morris wrote: > > >>Why aren't you using the copy task? >>http://ant.apache.org/manual/CoreTasks/copy.html > > > > The OP said "I just want to learn how to use exec task" > > Under a real OS shell, this works fine: > > <target name="test"> > <exec executable="cp"> > <arg value="/tmp/foo"/> > <arg value="/tmp/bar"/> > </exec> > </target> > > It's got nothing to do with the OS or how "real" you perceive it be. It has to do with the fact that he is actually not executing in any shell. "copy" is a shell command, not a Windows executable. If all the OP wants to do is experiment with the <exec> task, he should try a real executable, like notepad.exe or calc.exe. Ray -- This signature intentionally left blank. Raymond DeCampo |
|
|
|
#5 |
|
Posts: n/a
|
On Sat, 2006-04-01 at 02:38 +0000, Raymond DeCampo wrote:
> > It's got nothing to do with the OS or how "real" you perceive it be. > It > has to do with the fact that he is actually not executing in any > shell. > "copy" is a shell command, not a Windows executable. The user shouldn't have to know that. If "copy" would work from the command line where you ran "ant" it should work, whether it's a bat file, a bash script under cygwin, a dos command.exe built-in, an alias, an alternative "copy" early in the PATH environment, or whatever else is appropriate in a given context. James McGill |
|
|
|
#6 |
|
Posts: n/a
|
James McGill wrote:
> On Sat, 2006-04-01 at 02:38 +0000, Raymond DeCampo wrote: > >>It's got nothing to do with the OS or how "real" you perceive it be. >>It >>has to do with the fact that he is actually not executing in any >>shell. >> "copy" is a shell command, not a Windows executable. > > > The user shouldn't have to know that. If "copy" would work from the > command line where you ran "ant" it should work, whether it's a bat > file, a bash script under cygwin, a dos command.exe built-in, an alias, > an alternative "copy" early in the PATH environment, or whatever else is > appropriate in a given context. > Whether or not you think it "should" work, the fact is it does not. One should be familiar with the environment one is working in and understand how to get things done. If you are using the <exec> task, you;ve tied yourself to an OS and you'd better do it right for that OS. Furthermore, the only reason such things appear to work in other environments is that many versions of *nix include an executable for things like "cp". So your contention is that exec task for ANT should behave exactly the same as the command interpreter for the shell that invoked it. There are a few problems with that: first, the build script becomes dependent on the shell; second, how does ANT determine which shell it was invoked from; third, what do you do when ANT was not invoked from a shell at all (e.g., from inside of an IDE). I'm sure there are more reasons this is a bad idea, these are just the first ones that came to mind. Ray -- This signature intentionally left blank. Raymond DeCampo |
|