问题
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?
回答1:
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.
回答2:
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.
来源:https://stackoverflow.com/questions/18988830/how-can-i-trigger-an-ant-task-only-if-input-is-newer-than-output