I agree using entities to include document fragments is ugly. I have used a
stylesheet to create a build.xml file and then use it as a subprocess. It seems
like a good approach that exploits the fact that ant build files are XML!

 <target name="cooker" depends="xml/cook.xsl">
  <style
   style="xml/cook.xsl"
   in="xml/place_index.xml"
   out="place_cook.xml"
  />
 </target>

 <target name="cookit" depends="cooker">
  <ant antfile="place_cook.xml"/>
 </target>


Jason Pettiss wrote:

> Yep.  You can statically include other xml snippets using the XML semantics
> for doing so.  The only bad part of this is that the snippets themselves are
> not well-formed XML documents.  The &loadProperties; below is where the
> snippet gets 'pasted'.
>
> <?xml version="1.0"?>
> <!DOCTYPE project SYSTEM "../../../sitewide/build/project.dtd" [
>         <!ENTITY sitewideTargets SYSTEM
> "../../../sitewide/build/sitewideTargets.xml">
>         <!ENTITY loadProperties SYSTEM
> "../../../sitewide/build/loadProperties.xml">
> ]>
> <project name="myproj" default="main" basedir="..">
>
>   &loadProperties;
>
>   <path id="project.classpath">
>                 <path refid="sitewide.lib.classpath"/>
>         </path>
>
>   &sitewideTargets;
>
> ...
>
> jason pettiss
> AGEA Corporation
> http://www.agea.com
>
> -----Original Message-----
> From: Krzysztof Czarny [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, September 11, 2001 3:33 AM
> To: ant
> Subject: Some targets inside another buildfile
>
> Hi!
> Every project's buildfile that I wrote has some common
> parts. E.g.:
> <property name="build.classesdir"
>           value="${build}/classes"/>
> <target name="compile">
>   <mkdir dir="${build.classesdir}"/>
>   <javac srcdir="${src}"
>          destdir="${build.classesdir}"/>
> </target>
> I'd like to move them into another common buildfile
> and then 'include' this new buildfile into the main
> project buildfile and use them in a normal way:
>
> <!-- main project buildfile -->
>
> <property name="src" value="."/>
> <property name="build" value="build"/>
> <include file="common.xml"/> <!-- it uses defined
> property -->
> <target name="test" depends="compile">
>   <echo message="${build.classesdir}"/>
> </target>
>
> Is it possible?
>
> Regards,
>   Krzysztof
>
> __________________________________________________
> Do You Yahoo!?
> Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger
> http://im.yahoo.com

Reply via email to