ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <>
Subject RE: Including files in build files
Date Fri, 05 Jul 2002 15:28:38 GMT
Answers below. --DD

-----Original Message-----
From: [] 
Sent: Friday, July 05, 2002 9:48 AM
Subject: Including files in build files

Hello everybody
I'm about to prt existing Makefiles to Ant build scripts and came across
some problems:

My Makefiles all include a common include file with common settings and
targets for all my independent sub-projects. I'm quite happy with that
concept and therefore would like to know if there is a similar feature in
Ant too. I've read something in the FAQs that I could perform this the
XML-way. But this looks pretty nasty to me, keeping in mind that the reason
for using common include files is to make the actual build scripts very,
very simple.

[DD] No in official Ant yet, but by using the provided patch (to a single
source file) on Ant 1.5 from CVS (ANT_15_BRANCH), you can compile yourself a
distrib of Ant that supports <import>: 

Also, see for
an alterative way to emulate <import> without having to modify Ant at all.
The only drawback I see is that you must play with the Ant classpath to find
your common.xml (instead of being able to do that in the build.xml itself),
and specify that property to get the new type of URL stream handler
registered with the VM (but the latter can be dealt with by either modifying
ant.{bat|sh} or using ANT_OPTS).

I personally think that <import> as implemented is not that clean, because
of the fact that current Ant uses SAX to build the project file instead of
DOM. Using the DOM (or jdom, or whatever), if would be trivial to implement
<import>, and make it even more powerful by use XPATH-like query strings to
import selective part, modify attributes/properties of the pieces imported,
with features similar to xslt. But that's too big a programming challenge
for me. More than you wanted to know I'm sure... ;-)

Is there a built-in property providing the current target? This is nice for
recursive propagation without writing indivual targets.

[DD] Not built-in to Ant. But Diane Holt posted a little <script>let that
did just that. See
and the two 'Next in Thread' posts. 

Can I refer to environment variables?

[DD] Yes, using
<property environment="env"/>
<property name="Value of Path env. var." value="${env.Path}"/>

Jan Lessner

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message