ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rolf Katzenberger <rf...@gmx.net>
Subject Re: "overriding" a target
Date Sat, 05 Jan 2002 18:13:48 GMT
Hi Clint

On Fri, 4 Jan 2002 17:36:05 -0500 , "Combs, Clint"
<clint.combs@contrado.com> wrote:

>My company is using ant for all our Java builds.  We have a primary build
>file, called common.xml, and all include files named project-name.xml
>include this file via a line like:
>
><!ENTITY include.commontasks SYSTEM "file:./common.xml">
>
>This works great, but I have a project where I'd like to extend the "clean"
>target that is found in common.xml.  In other words, I'd like to define the
>"clean" target in project-name.xml to do everything in common.xml, plus a
>few more things.  Obviously, I could define another target name which
>depends on clean, but that would break the overall build process, which
>calls clean automatically on each project.

How about the approach described below?

Regards,
Rolf


common.xml:

  <property name="clean.target" value="clean.commontasks" />

  <target name="clean">
    <antcall target="${clean.target}" />
  </target>

  <!-- The common clean target: -->
  <target name="clean.commontasks">
    <echo message="Now executing commontasks clean..." />
  </target>

The project build.xml:

  <?xml version="1.0"?>

  <!DOCTYPE project [<!ENTITY common SYSTEM "file:./common.xml">]>

  <project name="myproject" default="test" basedir=".">

    <!-- Comment this out and clean.commontasks will be called: -->
    <property name="clean.target" value="clean.myproject" />
	
    &common;

    <target name="test" depends="clean" />
      <!-- The overriding clean target: -->
      <target name="clean.myproject">
        <antcall target="clean.commontasks" />
        <echo message="Now executing project clean..." />
      </target>
  </project>

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message