在webapp中获取当前的svn修订版 [英] obtain current svn revision in webapp
问题描述
在java webapp中显示/使用修订号的最佳方法是什么?
what is the best way of displaying/using the revision number in a java webapp?
我们只使用ant来构建我们的.war存档,没有构建服务器或者这样的。我希望有一些我可以在资源文件中编写的$ ref,但只有在提交相关文件时才会更新。我需要全球。
we just use ant to build our .war archive, no buildserver or such. i'd hope there was some kind if $ref that i could write in a resource file, but this is only updated when the file in question is committed. i need it globally.
你会推荐什么?更新某些文件的提交后触发器?
自定义蚂蚁脚本?有没有更黑的方式这样做?
或者最好让我自己的版本号独立于svn。
what would you recommend? post-commit triggers that update certain files? custom ant scripts? is there a more non-hacky way of doing this? or it it better to have my own version number independent of svn.
编辑:很棒的建议!非常感谢你的答案!
edit: great suggestions! thanks a lot for the answers!
推荐答案
有几个Ant任务可以帮你完成。
SvnAnt任务来自底格里斯河是最古老的。
SvnAnt task from tigris is the oldest.
文件是这里 - 特别是看一下 info
元素,它将Subversion存储库的修订版号公开为一个Ant属性,它调用转
。您可以使用正常的Ant替换机制将此值写入您的资源文件。
Documentation is here - in particular take a look at the info
element which exposes the Subversion repository's revision number as an Ant property which it calls rev
. You can write this value to your resouces file using the normal Ant substituion mechanisms.
有人还提出了 simillar(更简单)任务 - 从未使用它,但无法发表评论。
Someone has also put up a simillar (simpler) task on google code hosting - never used it though so can't comment.
如果你的构建中已经有Ant,那么这些对我来说似乎是最好的方式。
Either of these seem like the neatest way to me if you already have Ant in your build.
这篇关于在webapp中获取当前的svn修订版的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!