You have a problem with a build file, and you would like to track it down.
The current version of Ant displays syntax errors for Ant scripts only when you try to run them. However, Eclipse 3.0 does catch and display syntax errors as they're created.
| || |
This is an Eclipse 3.0-only solution.
Eclipse does offer some support for catching syntax errors when you write Ant scripts. However, the Eclipse editor catches syntax errors only if your XML documents are not well formed in the XML sense (e.g., nesting errors, omitting quotes for attribute values, etc.). You can see an example in Figure 7-7, where we've omitted the quote in front of the text jarFile , which is being assigned to an attribute in the <property> element.
Figure 7-7. An XML error in an Ant script
Note, however, that although the Ant editor indicated that the XML was not well formed, it entirely missed the fact that the <property> element's name attribute is misspelled as nane , as shown in the figure.
On the other hand, when you try to run this script, Ant will realize there's a syntax error, and you'll get the results you see in Figure 7-8, where the syntax error is indicated.
Figure 7-8. An Ant error
Eclipse will show you the syntax error when you try to run the script, but it's up to you from that point; no Quick Fixes are available. Nor can you interactively debug Ant scripts (yet).
| || |
Actually, it's worth noting that the Ant editor does offer code assist for Ant build files. For example, if you enter < and pause, code assist displays a list of possible Ant build file elements, and you can select one. Code assist also lists possible attributes of Ant elements; just place the cursor inside the opening tag of an Ant element, and press Ctrl-Space.
22.214.171.124 Eclipse 3.0
Eclipse clearly knows whether syntax errors are in your Ant script (see Figure 7-8), so why can't it tell you as you're writing them? In Eclipse 3.0, it can. Now, Ant-specific errors are shown in the Ant editor with the typical wavy red lines, as shown in Figure 7-9, where the editor is catching the nane syntax error.
Figure 7-9. Catching a syntax error
This is a considerable improvement. However, Eclipse developers are still awaiting interactive Ant script debugging and wizards that will enable you to create scripts visually. Maybe one day we'll see these items.
7.3.4 See Also
Chapter 5 of Eclipse (O'Reilly).