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

扶醉桌前 提交于 2020-01-15 09:27:28

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!