File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Rather simple ant question" Watch "Rather simple ant question" New topic

Rather simple ant question

Neha Gap

Joined: May 30, 2007
Posts: 29

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.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17410

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.


An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: Rather simple ant question
jQuery in Action, 3rd edition