< Day Day Up > |
Recipe 7.3 Catching Ant Build File Syntax Problems7.3.1 ProblemYou have a problem with a build file, and you would like to track it down. 7.3.2 SolutionThe 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.
7.3.3 DiscussionEclipse 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 scriptNote, 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 errorEclipse 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).
7.3.3.1 Eclipse 3.0Eclipse 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 errorThis 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 AlsoChapter 5 of Eclipse (O'Reilly). |
< Day Day Up > |