aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes Rather simple ant question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Rather simple ant question" Watch "Rather simple ant question" New topic
Author

Rather simple ant question

Neha Gap
Greenhorn

Joined: May 30, 2007
Posts: 29
Hi,

I want to know how to use the special characters (like < ) in an ant build file.

I'm trying to create a target in my ant file to execute a script in mysql. Since mysql has no options for input file, on the command prompt, it can be done using the < filename.sql option. However, putting the < character in the arg section of exec task in an ant file gives errors.

Any help would be really appreciated.
Thanks!
Neha.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16145
    
  21

OK, there's several issues here.

First, an Ant build.xml file is (suprise!) an XML file. The < > " & and ' characters cannot be used directly, since they all have meaning as XML lexical elements, so instead you either have to use a CDATA or an entity (&lt; &gt; &quot; &amp; and &apos .

But that's not enough. The '<' character has no special meaning to Ant as regards I/O piping and redirection - that functionality is provided by the user's command shell. SO what you really need isn't a way to code a redirection, but rather a specific redirection directive.

Example:


Customer surveys are for companies who didn't pay proper attention to begin with.
 
wood burning stoves
 
subject: Rather simple ant question