Go Back   Velocity Reviews > Newsgroups > Java
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

Java - about <exec> tag in ant

 
Thread Tools Search this Thread
Old 03-31-2006, 05:00 PM   #1
Default about <exec> tag in ant


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
  Reply With Quote
Old 04-01-2006, 12:57 AM   #2
Tony Morris
 
Posts: n/a
Default Re: about <exec> tag in ant
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
  Reply With Quote
Old 04-01-2006, 01:53 AM   #3
James McGill
 
Posts: n/a
Default Re: about <exec> tag in ant
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
  Reply With Quote
Old 04-01-2006, 03:38 AM   #4
Raymond DeCampo
 
Posts: n/a
Default Re: about <exec> tag in ant
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
  Reply With Quote
Old 04-01-2006, 04:06 AM   #5
James McGill
 
Posts: n/a
Default Re: about <exec> tag in ant
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
  Reply With Quote
Old 04-02-2006, 04:00 AM   #6
Raymond DeCampo
 
Posts: n/a
Default Re: about <exec> tag in ant
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
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46