5.4 Catching Errors in Build Files


Eclipse gives you some support for catching Ant errors before you run Ant, but not much. The Eclipse Ant editor doesn't handle syntax errors as the JDT editor does for Javafor example, if you misspell the project element's default attribute as deefault , the Ant editor won't have a problem. However, if the XML in your build file has syntax errors, such as missing a closing tag or improper nesting (in XML terms: if your XML is not well- formed ), you'll see the same wavy red line and hollow red box you see in the JDT editor in the Ant editor, indicating a syntax error, as shown in Figure 5-12. You can determine what error occurred by looking at the wavy line's tooltip, as shown in the figure, where we haven't closed the mkdir element.

Figure 5-12. Handling a syntax error

If you miss an XML error like this in the editor, you'll see a message reminding you of it as soon as you try to run Ant to build the project. The Ant editor doesn't display non-XML syntax errors (like misspelling the project attribute as deefault ), but you'll automatically see any syntax errors listed when you try to run Ant, as shown at the top of Figure 5-13.

Figure 5-13. An error description

Unfortunately, that's as much support as Eclipse gives you for handling Ant errorswhen Ant runs, it'll display its own errors in the Console view, and it's up to you to take it from there (although Eclipse does hyperlink errors to the associated lines in the build or Java file). Eclipse doesn't support interactive debugging of Ant scripts yet, which is a pity, given how complex those scripts can become. Perhaps we'll see that one day in Eclipse; in fact, given the popularity of Ant, it's possible that future versions of Eclipse may include an Ant wizard, invoked with File New, that will let you set up build targets, directories, and Ant tasks as easily as creating a new Eclipse project.

ISBN: 0596006411
EAN: 2147483647
Year: 2006
Pages: 114
Authors: Steve Holzner

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net