Marcus Junius Brutus
Marcus Junius Brutus

Reputation: 27286

How can I trigger an ant task only if input is newer than output?

I have a build process in Java where I need to use the Ant exec task to launch an external program. That external program will then create some sources based on an abstract specification, i.e. a kind of code generation.

How can I get the exec task to execute only if the input to the code generation is newer than the output? I.e. when the input has been modified after the output was last created?

Upvotes: 1

Views: 255

Answers (2)

Marcus Junius Brutus
Marcus Junius Brutus

Reputation: 27286

Since I wanted to specify an arbitrary set of target files (which is cumbersome or impossible with Uptodate that only uses the Ant mapper element for multiple target files), I ended up using the ant-contrib OutOfDate task which supported what I wanted more intuitively.

Upvotes: 1

joescii
joescii

Reputation: 6533

Use the Uptodate task to set a property and add an if or unless with that property to the target which contains your exec task.

Upvotes: 2

Related Questions