ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alex Solofnenko" <>
Subject RE: Dynamic Targets
Date Sat, 24 Feb 2001 06:07:51 GMT

  XSLT preprocessor will help. You can create a template for node <project-target name="utils">
and then use "{@name}" in the template to be substituted with project name.

Example build.xml (I call Xalan externally because I run the script from JBuilder and it is
difficult to specify relative classpath there):
  <property name="build" value="real_build.xml"/>
  <property name="xsl"   value="rreal_build.xsl"/>
  <property name="generated_build" value="real_build_gen.xml"/>

  <target name="script-check">
    <uptodate property="scriptUptodate" targetfile="${generated_build}">
      <srcfiles dir="." includes="${build},${xsl}"/>

  <target name="script" depends="script-check" unless="scriptUptodate">
    <echo message="Generating build script..."/>
    <java classname="org.apache.xalan.xslt.Process" fork="yes" failonerror="yes">
      <arg value="-IN"/>
      <arg value="rv_build.xml"/>
      <arg value="-XSL"/>
      <arg value="rv_build.xsl"/>
      <arg value="-OUT"/>
      <arg value="rv_build_gen.xml"/>
        <pathelement path="Runtime/ThirdParty/lib/xalan.jar"/>
        <pathelement path="Runtime/ThirdParty/lib/xerces.jar"/>
      <sysproperty key="org.xml.sax.driver" value="org.apache.crimson.parser.XMLReaderImpl"/>

  <target name="make" depends="script">
    <echo message="Executing build script..."/>
    <ant antfile="${generated_build}" target="${target}"/>

!! Do not forget to add "default" template into your XSLT:

  <xsl:template match='@*|node()' >
      <xsl:apply-templates select='@*|node()'/>

  Alexey Solofnenko.

View raw message