wood burning stoves 2.0*
The moose likes Ant, Maven and Other Build Tools and the fly likes How does ant know what to avoid doing? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "How does ant know what to avoid doing?" Watch "How does ant know what to avoid doing?" New topic
Author

How does ant know what to avoid doing?

paul wheaton
Trailboss

Joined: Dec 14, 1998
Posts: 20637
    ∞

I must be having a brain fog day.
I'm trying to wrap my head around the idea of how ant knows when to avoid doing work that doesn't need to be done. I think compiling java is straightforward, but what about other stuff.
Suppose I have a directory tree full of *.xxx files. And another directory tree full of *.yyy files.
Suppose I have /src/animals/cows/bessie.xxx that has a timestamp later than /dest/animals/cows/bessie.yyy. But /src/animals/cows/gertrude.xxx has a timestamp earlier than /dest/animals/cows/gertrude.yyy. Because of this, I need to run "mash /src/animals/cows/bessie.xxx -dest /dest/animals/cows/" but not run mash for gertrude.
What ant script would do that?


permaculture Wood Burning Stoves 2.0 - 4-DVD set
paul wheaton
Trailboss

Joined: Dec 14, 1998
Posts: 20637
    ∞

To expand on my question a bit, take a look at the jar tag.
Does it just call the JDK jar stuff, or does it first figure out if it needs to do a jar at all?
Lewin Chan
Ranch Hand

Joined: Oct 10, 2001
Posts: 214
Paul,
Having never inspected the ant source, this won't be a definitive answer.
For any operation where there is a destination file (and source files), if the destination file is considered more recent than any of the source files, then that the operaion won't then take place.
For instance,

You may find in this instance that the jar never actually contains the files from classes2.
L


I have no java certifications. This makes me a bad programmer. Ignore my post.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
It fully depends on how the specific task is implemented.
The jar task, for example, does try to examine wether the jar needs to be updated, but only uses time stamps for this - so if the jar file is newer than the file you want to add, it won't get added even if it isn't yet contained in the jar. Bug 10755 is about this problem - a workaround is to manipulate the time stamps using the touch task.
If a task doesn't support conditional execution, you can use the uptodate task to set a property and conditionally execute a target.
Did that help?


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
paul wheaton
Trailboss

Joined: Dec 14, 1998
Posts: 20637
    ∞

Thanks guys.
That's the answer I was hoping for: jar is not just simply called. Ant looks at the timestamps of files to see if the whole jar thing can be skipped.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How does ant know what to avoid doing?