Mon, 13. Oct 2003
If you want to include a common snippet of build file code in Ant, the canonical answer has been to use entity includes. Consequently this is what you find in Ant's FAQ.
Ant 1.6 adds an import tasks that can be used to include such snippets as well. The task can do more than that, but I only want to cover the include mechanism right now.
So what is the difference?
-
Files suitable for <import> must be legal Ant build files, i.e. they have to be well-formed XML documents and use <project> as their root element.
This means that - unlike the snippets you use in entity includes - the included file can easily be edited and (partly) validated with XML aware tools.
- You can use Ant properties in the file name for the piece to include in <import>. With entity includes you've been limited to static file names and hard-coded (relative) paths.
- You don't have to worry about the way your XML parser resolves relative file names.
- Entity includes require a DOCTYPE declaration and thus have their roots in DTD systems. If you have an XML-Schema or Relax-NG gramar for Ant build files, the two are hard to combine.
- You must not use <import> inside a <target> (or <sequential>), while there is no such limitation for entity includes.
path: /en/Apache/Ant | #