Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2006

Tip: Looking for answers? Try searching our database.

about <exec> tag in ant

Thread view: 
david wolf - 31 Mar 2006 17:00 GMT
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(ExecTask.java:620)
       at
org.apache.tools.ant.taskdefs.ExecTask.execute(ExecTask.java:452)
       at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
       at org.apache.tools.ant.Task.perform(Task.java:364)
       at org.apache.tools.ant.Target.execute(Target.java:341)
       at org.apache.tools.ant.Target.performTasks(Target.java: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.executeTargets(DefaultExe
Tony Morris - 01 Apr 2006 00:57 GMT
> I am trying to use <exec> tag in ant to call an native executable. When
> I use the command:
[quoted text clipped - 43 lines]
>         at
> org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExe

Why aren't you using the copy task?
http://ant.apache.org/manual/CoreTasks/copy.html

Signature

Tony Morris
http://tmorris.net/

s/Commonwealth Games/Commonwealth Swimming

James McGill - 01 Apr 2006 01:53 GMT
> 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>
Raymond DeCampo - 01 Apr 2006 03:38 GMT
>>Why aren't you using the copy task?
>>http://ant.apache.org/manual/CoreTasks/copy.html
[quoted text clipped - 9 lines]
>         </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

Signature

This signature intentionally left blank.

James McGill - 01 Apr 2006 04:06 GMT
> 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.  
Raymond DeCampo - 02 Apr 2006 04:00 GMT
>>It's got nothing to do with the OS or how "real" you perceive it be.
>>It
[quoted text clipped - 7 lines]
> 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

Signature

This signature intentionally left blank.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.