Pierre
Pierre

Reputation: 35246

Prevent Ant from performing a task if a file is older than another file

how can I prevent Ant from processing a task if a source file is older than the current target. For example, I created a javacc file MyParser.jj and there is no need for javacc to re-generate the file MyParser.java as long as the MyParser.jj is older than MyParser.java.

Upvotes: 1

Views: 257

Answers (2)

Aaron Digulla
Aaron Digulla

Reputation: 328614

There must be a bug elsewhere or your version of Ant is too old. From the docs:

This task only invokes JavaCC if the grammar file is newer than the generated Java files.

Upvotes: 2

abyx
abyx

Reputation: 72808

As Aaron said, the javacc task shouldn't be executed on code that hasn't changed.

But, to answer to original question - there's an uptodate task that can be used for this purpose. Here's an example.

Upvotes: 2

Related Questions