ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Clifton Craig <>
Subject Re: Perform tasks conditionally
Date Mon, 09 Jan 2006 19:25:02 GMT

The jar task compares the timestamps of all the files you wish to jar to the 
preexisting complete jar (if it had been run before) and will not execute if 
none of them are later than the timestamp of the existing jar. Working 
backwards from there you have the javac task which compares the timestamps of 
all the source files with their corresponding class files and skips the ones 
that it doesn't need to compile. The end result is if you touch any source 
file it will trigger a recompile which will trigger a re-jarring. In fact all 
(most?) of ant's tasks are designed this way with optimization for 
incremental builds. My take is that you have changed some default of the 
javac task that could be always recompiling your source or maybe you-re using 
some force attribute on your jar task? Could it be that maybe you're using a 
copy task (copying configs to the output folder) with a force attribute which 
would also trigger a rejarring as the copied files would appear newer than 
the jar? Maybe you're just getting confused by the build logs which log the 
jar task even when it skips operation? Careful starting out new as I was in 
the same ship a couple years ago and had the same problem. I can't remember 
how but I think I was dumping my class output somewhere special and telling 
the javac task to use something different for figuring out what to compile. 
The heart of the problem was that I was forcing something where I didn't 
understand the default behaviour and caused a whole lot of problems down he 
line when I had to maintain it.
Clifton C. Craig, Software Engineer
Intelligent Computer Systems -  A Division of GBG

On Friday 06 January 2006 9:24 pm, Steve Roy wrote:
> Hello,
> I have been using Ant for about a year but I still feel like I am a
> newbie, and maybe this explains my question, but you tell me.
> I have a script where I compile the sources for my project and jar it
> all up. This works well but I'm looking at adding an optimization where
> the Jar task would be skipped if no source file had to be recompiled.
> How could I do that?
> I looked at the Condition task, but that didn't light up anything in my
> mind. I'm guessing that I need to find out from the Javac task how many
> files had to be compiled, but how would I do that?
> Steve

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

View raw message