Setting ant property with bash command result

廉价感情. 提交于 2019-12-07 21:46:56

问题


How could I set ant property the value which is the result of bash script execution? For example, I need to have target which utilizes svn and bash utilities in order to control build execution. Speaking more specifically, target that I'm trying to create will be used to define, whether there are modified files in deployed application via command:

svn stat | awk -F ''  ' $1=="A" || $1 == "C" || $1=="M" || $1 == "D" || $1 == "R" {print $1}' | wc -l

I need to set the result of this command to some ${modified_lines_number} property.


回答1:


Assuming you're using the exec task to run that command, that task has an outputproperty attribute that lets you specify the name of a property in which to store the output.




回答2:


You could capture the output of your command like this:

OUTPUT=$(snv stat | ... | wc -l)

...and define a property for ant like this:

ant -Dmodified_lines_number=$OUTPUT


来源:https://stackoverflow.com/questions/1487887/setting-ant-property-with-bash-command-result

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