File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Ant, Maven and Other Build Tools and the fly likes Trouble launching ant exec task Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Reply Bookmark "Trouble launching ant exec task" Watch "Trouble launching ant exec task" New topic
Author

Trouble launching ant exec task

Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 434
Hi,

I'm using Ant 1.7 on Mac 10.6.3. In my .bash_profile, I have defined an alias called "restart", that runs some commands. I would like to execute this same alias in my ant task, but '<exec executable="restart" />' isn't working. Here is my larger target ...



Instead I get the error ...

/Users/davea/projects/LVCVA/LVCVA/ant/build.xml:293: Execute failed: java.io.IOException: Cannot run program "restart" (in directory "/Users/davea/projects/LVCVA/LVCVA/ant"): error=2, No such file or directory

Any ideas what I can do to address the problem? Thanks, - Dave
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5532

I don't think you can <exec> an alias. An alias is something defined to bash and is specific to bash, whereas <exec> communicates to the OS (not to bash). So try <exec>ing bash, passing the alias to bash.


JBoss In Action
Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 434
You mean pass in "bash" as the executable and have my aliased command as my argument? - Dave
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Or define it as a shell script as opposed to an alias--arguably cleaner.
Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 434
So when I do this



is the second exec waiting for the first to complete? If not, how can I force that? Also, normally I see output from these commands but I don't when I run the ant task. Anyway to get it pipe the output to the terminal?

Thanks, - Dave
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Why not use the Tomcat Ant tasks?
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5532

Dave Alvarado wrote:You mean pass in "bash" as the executable and have my aliased command as my argument? - Dave

Yes. Check out the -c option in the bash man pages.

Also, you can run a script directly via <exec>, you do not have to do it via bash.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Trouble launching ant exec task
 
Similar Threads
ant javac task not copying directory with no java files
How to make a part of a target conditional?
Ant does not output property file in classes folder.
Obfuscating Package Names
Possible to execute a target only if files have changed?