Hi "Craig R. McClanahan" <[EMAIL PROTECTED]> writes: > Scott M Stark wrote: > > > Is there a mechanism like the gnumake include or -include in Ant? > > I tried using an xml:link hoping the parser would just magically > > include it but Ant sees the include element and wants to treat it > > as a task. > > There is not an "include" mechanism like what you're describing in > Ant right now. However, it would not be hard using some of the > shell tools that manipulate text files to construct a buildfile on > the fly by copying in standard components, before feeding the > resulting file to Ant. You could do this with the C preprocessor > (cpp), or the m4 utility, for example.
Using shell tools is not a good solution as the purpose of Ant is independancy against platform. But build.xml files are XML files (obviously), so you can use entities to include another XML file, like that : file build.xml ---------------------------------------------------------------- <?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE project PUBLIC "-//ANT//DTD project//EN" "project.dtd" [ <!ENTITY include SYSTEM "message.xml"> ]> <project name="test" default="task" basedir="."> <target name="task"> <echo message="Hello"/> &include; </target> </project> ---------------------------------------------------------------- This file includes the following : file message.xml ---------------------------------------------------------------- <echo message="World !"/> ---------------------------------------------------------------- Thus when running ant, you get : [casa test]$ ant Buildfile: build.xml Project base dir set to: /home/casa/tmp/test Executing Target: task Hello World ! Completed in 2 seconds But you must have a DTD for project files :o) -- +---------------------------+--------------------------------+ | Michel CASABIANCA | http://www.sdv.fr/pages/casa | | mailto:[EMAIL PROTECTED] | Articles sur Java et XML | | D�veloppement Java et XML | Applications et Applets de Jeu | +---------------------------+--------------------------------+
