ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Timothy Wall <>
Subject Re: AW: Conditional target execution based on prerequisite execution
Date Tue, 18 Feb 2003 16:01:54 GMT
The goal is not "run A before B" (although that may be a requirement).  
The goal is "only run B if it is out of date".  Ant by default runs 
(almost) everything all the time.

If B takes nonzero time to run, I *only* want it to run if B is "out of 
date".  Normally, a target would be considered out of date if
a) any of its "depends" is out of date (and thus gets run)
b) some other prerequisites are not satisfied (i.e. .java is newer than 
.class, or the .jar file is not yet built)

Some examples of standard conditional execution:

idl parsing/code generation: generate .java code only if .idl files 
have been modified
jar file: only run jar if the class files it depends on have been 
java compiler: only compile if .java is newer than .class

The last is the only thing that I've seen ant handle automatically, 
although I seem to have a knack for configuring things such that it 
recompiles everything every time.

On a complex project, typically you'll have many smaller targets with 
internal dependencies (and some with prerequisit targets as 
dependencies) and several overall targets that primarily consist of 
prerequisite target dependencies (a jar file or shared library, for 

On Tuesday, February 18, 2003, at 10:23 AM, 

> When you use <target name="B" depends="A"/> the Ant framework will
> invoke A before B. Why setting a property?
> BTW the "onlyif" is <target if="propertyname"/>
> There is a unless="propertyname", too.
> Jan Matèrne

View raw message