使用SVN将一些模板文本包含到源文件中的好方法? [英] A good solution to include some template text into a source file using SVN?

查看:104
本文介绍了使用SVN将一些模板文本包含到源文件中的好方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在SVN存储库中有一个Java项目,带有一堆.java文件,每个文件在文件顶部都有一个许可协议花箱(我的客户已经许可了源以及正在运行产品)。

I have a Java project in a SVN repository, with a bunch of .java files, each of those files has a licence agreement flower box at the top of the file (I have customers which have licenced the source as well as running the product).

是否有一种很好的方法可以在一个地方修改/维护许可文本,而不是必须手动更新所有源文件?

Is there a good way to be able to modify / maintain the licence text in one place rather than having to update all the source files manually if it changes?

看一些类似(但不完全相同)的问题,似乎SVN没有开箱即用的这种功能 - 其他哪种方法最适合?

Looking at some similar (but not identical) questions it seems like SVN does not have this functionality out of the box - what other approaches would be most suitable?

编辑:理想情况下,解决方案的行为类似于SVN关键字(Id,Author等),而不是构建时解决方案。客户也可以访问SVN存储库,因此如果许可证文本存在于文件的SVN版本中,那将是理想的。我知道SVN有提交触发器 - 实现它的简单方法是什么?

Ideally the solution would act like the SVN keywords (Id, Author etc.) rather than being a build-time solution. The customer has access to the SVN repository too, so it would be ideal if the licence text was present in the SVN version of the file. I know SVN has commit triggers - what's a simple way to implement that?

编辑2:看看SVN钩子它看起来不像我想要的做是可能的。我想在文本更改时可以运行的构建过程是正确的 - 因为它不会经常更改。

Edit 2: Looking at the SVN hooks it doesn't look like what I'd like to do is possible. I guess build process that can be run when the text changes is ok - since it won't change too often.

推荐答案

修改需要包含许可证文本以包含某些令牌的源文件,然后将许可证文本移动到保存在subversion中的单个文件中。最后,作为构建过程的一部分,添加一个步骤,用于替换令牌的许可证文本。在我的工作中,我使用sed和make的组合在这些方面做了一些事情。然后,您可以在将源分发给客户之前执行此单步。

Modify the source files that need to contain the text of the license to contain some token instead, and then move the license text to a single file that's kept in subversion. Finally, as part of your build process, add a step that substitutes the text of the license for the token. At my job, I do something along these lines using a combination of sed and make. You could then execute this single step before distributing the source to your customers.

这篇关于使用SVN将一些模板文本包含到源文件中的好方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆