ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kendall Shaw <>
Subject Re: Not a FAQ? make-like build prerequisites
Date Tue, 13 Jul 2004 04:56:59 GMT
Dominique Devienne wrote:
>  -- Makefile --		-- build.xml --
> %.class:		<javac>
> 	javac ...
> %.html: %.xml
> 	xsltproc ...	<style>
> etc...
> In those cases where there's no built-in task that handles automagically the
> dependencies, <outofdate> allows you to do just that. Using a <fileset> for
> source files and a <mapper> for the target files (inferring the target
> file's name from the source), you pretty much fully emulate the
> %.source functionality of a Makefile.

But, I'm talking about the situation in which you have more than one rule.

Take this Makefile as an example (ignoring platform issues):

c.txt: b.txt
    touch c.txt
    echo C

b.txt: a.txt
    touch b.txt
    echo B

    touch a.txt
    echo A

It consists of 3 rules, and their associated commands.

Rule #1: match, if c.txt is out of date with respect to b.txt
Rule #2: match, if b.txt is out of date with respect to a.txt
Rule #3: always match (if in scope)

It is not a script, in the usual sense, and very different from ant 
target elements and their depends attributes. For example, this file:

<?xml version="1.0"?>
<project default="c">
   <target name="c" depends="b">
	<touch file="c.txt"/>
   <target name="b" depends="a">
	<touch file="b.txt"/>
   <target name="a">
	<touch file="a.txt"/>

The depends attributes indicate the sequence of targets to run, not 
anything having to do with file uptodateness. The depends attribute 
means (I gather), before executing this target, execute the targets 
listed in the depends attribute.

Compare the effects:

Case #1: None of a.txt, b.txt or c.txt exist

a) Make: the 3 files are touched, and A, B and C are echoed in sequence
b) Ant: the 3 files are touched, and A, B and C are echoed in sequence

Case #2: b.txt is newer than c.txt

a) Make: ONLY c.txt is touched, and ONLY C is echoed
b) Ant: the 3 files are touched, and A, B and C are echoed in sequence

Case #3: a.txt is newer than b.txt

a) Make: ONLY c.txt and b.txt are touched, and ONLY B and C are echoed
b) Ant: the 3 files are touched, and A, B and C are echoed in sequence

the result of running make on a makefile, is a series of actions that 
could be thought of as a script implied by the makefile, approximately, 
but not quite, this:

if b.txt is newer than c.txt, then
    if a.txt is newer than b.txt, then
       if a.txt doesn't exist, then
          touch a.txt
       touch b.txt
    touch c.txt

On the other hand, ant is really more like a script itself, which would 
be similar to:

touch a.txt
touch b.txt
touch c.txt

except expresseed as:

c: b(); touch c.txt
b: a(); touch b.txt
a: touch a.txt

Using dependset, outofdate, uptodate, condition, map etc., I can 
explicitily test file timestamps, and write a script in ant to execute 
ant targets conditionally.

In that case, I need to compare ant with other scripting languages. I 
don't think ant will turn out to be the ideal scripting language.

Good things about ant could still be used, by invoking ant from another 
build tool, e.g.:

.PHONEY: update_thingy

update_thingy: blah.jar
	ant -f deploy.xml -Djar.file=blah.jar

blah.jar: blah.jsp
	ant -f blah_jar.xml

it would also be trivial to encode the Makefile in xml to allow for 
integration with other tools, and to deal with the annoying tab 
character issue. It wouldn't take care of the annoying problem with 
spaces in file names though.

Anyway, thanks and hopefully I am wrong about ant.


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

View raw message