You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by "Combs, Clint" <cl...@contrado.com> on 2002/01/04 23:36:05 UTC
"overriding" a target
Hi,
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.
I saw discussions of extending tasks on this list a while ago, but nothing
about overriding/extending targets.
Is this sort of feature available now? If not, does it sound like a
reasonable idea? Would it be possible to add this?
Thanks,
Clint
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: "overriding" a target
Posted by Rolf Katzenberger <rf...@gmx.net>.
Hi Clint
On Fri, 4 Jan 2002 17:36:05 -0500 , "Combs, Clint"
<cl...@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: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>