To directly answer the question (whether it's a problem to skimp on license headers in unit test files out of laziness), my gut answer is probably not. Open-source purists and legal experts would probably say that you need to include the license in every source file. I think that's good practice, but failing to do so is not the end of the world, especially if your code comes with a LICENSE.txt file. Even more so for unit test code, which is probably not at all applicable outside the context of your project.
I'm obviously not a lawyer, but if someone were to use your source code in a way not conducive with your license, (LGPL in this case) I have trouble imagining that arguing that the license wasn't included in a particular source file would hold too much water. I would expect someone that wants to use the code to find out what the license is beforehand, and if someone were to steal your code and call it their own, it's not okay just because there wasn't a license header in the file. In my opinion, theft is theft, whether or not there's a sign that says "You're not allowed to steal this." :-) Unfortunately, that's unlikely to be sufficient in the complex world in which we live... (sigh)
Perhaps the best answer is "better safe than sorry", but go with your instinct and the guidance of experienced developers you trust. I guess that's why you asked on SO. ;-)
You might consider using a generic, boilerplate source file for your projects that include your name and a copyright notice. Copy it instead of creating a new file. Also be sure to check the dates and information before you check in to source control each file. This is an easy step.
Do you really care if someone "steals" your unit tests?
I am not a lawyer but ... AFAIK, There is no legal requirement to include the license in every source file, it's just that people like covering their butts. Including your license in a clear README.txt or LICENSE.txt and in the place where you publish your source should be good enough. If this is making you lose sleep just write a script that populates the license comment.
Update based on the comment:
If you really need to get this question answered in a definate manner I suggest you contact software freedom .org
#!/usr/bin/perl -w
use strict;
# Copyright Header Here
my $copyright_header = <<COPYRIGHT;
# MyProject v1.0
# Copyright Jader Dias, 2009
COPYRIGHT
open FILE, "<parse.pl" or die $!;
while ( my $line = <FILE> ) {
if ( $line =~ /\#\s*Copyright Header Here/ ) {
print $copyright_header;
} else {
print $line;
}
}
close FILE or die $!;
根据程序的结构,您可以用版权标头替换原始文件中的标签,或者仅将标头添加到文件的最顶部。
Adding copyright headers to every source file in your project is a very brief project for someone who knows a scripting language. If you don't know a scripting language like Perl, Python or Ruby, this is a good time to start learning one.
For example, here's a Perl script that adds a copyright header to itself:
#!/usr/bin/perl -w
use strict;
# Copyright Header Here
my $copyright_header = <<COPYRIGHT;
# MyProject v1.0
# Copyright Jader Dias, 2009
COPYRIGHT
open FILE, "<parse.pl" or die $!;
while ( my $line = <FILE> ) {
if ( $line =~ /\#\s*Copyright Header Here/ ) {
print $copyright_header;
} else {
print $line;
}
}
close FILE or die $!;
Depending on the structure of your program, you can either replace a tag in the original file with a copyright header, or just add the header to the very top of the file.
发布评论
评论(5)
为了直接回答这个问题(出于懒惰而在单元测试文件中省略许可证头是否是一个问题),我的直觉答案可能不是。 开源纯粹主义者和法律专家可能会说您需要在每个源文件中包含许可证。 我认为这是一个很好的做法,但不这样做并不是世界末日,特别是如果您的代码附带 LICENSE.txt 文件。 对于单元测试代码来说更是如此,它可能在项目上下文之外根本不适用。
我显然不是律师,但如果有人以不利于您的许可证的方式使用您的源代码(在本例中为 LGPL),我很难想象争论许可证未包含在特定源文件中会容纳太多的水。 我希望想要使用该代码的人事先找出许可证是什么,如果有人窃取您的代码并将其称为自己的代码,那么仅仅因为文件中没有许可证头就不行了。 在我看来,盗窃就是盗窃,无论是否有“不准偷这个”的牌子。 :-) 不幸的是,在我们生活的复杂世界中,这不太可能是足够的......(叹气)
也许最好的答案是“安全胜于遗憾”,但请遵循您的直觉和您信任的经验丰富的开发人员的指导。 我想这就是你这么问的原因。 ;-)
To directly answer the question (whether it's a problem to skimp on license headers in unit test files out of laziness), my gut answer is probably not. Open-source purists and legal experts would probably say that you need to include the license in every source file. I think that's good practice, but failing to do so is not the end of the world, especially if your code comes with a LICENSE.txt file. Even more so for unit test code, which is probably not at all applicable outside the context of your project.
I'm obviously not a lawyer, but if someone were to use your source code in a way not conducive with your license, (LGPL in this case) I have trouble imagining that arguing that the license wasn't included in a particular source file would hold too much water. I would expect someone that wants to use the code to find out what the license is beforehand, and if someone were to steal your code and call it their own, it's not okay just because there wasn't a license header in the file. In my opinion, theft is theft, whether or not there's a sign that says "You're not allowed to steal this." :-) Unfortunately, that's unlikely to be sufficient in the complex world in which we live... (sigh)
Perhaps the best answer is "better safe than sorry", but go with your instinct and the guidance of experienced developers you trust. I guess that's why you asked on SO. ;-)
您可以考虑为您的项目使用通用的样板源文件,其中包括您的姓名和版权声明。 复制它而不是创建新文件。 另外,请务必在签入每个文件的源代码控制之前检查日期和信息。 这是一个简单的步骤。
You might consider using a generic, boilerplate source file for your projects that include your name and a copyright notice. Copy it instead of creating a new file. Also be sure to check the dates and information before you check in to source control each file. This is an easy step.
您真的关心是否有人“窃取”您的单元测试吗?
我不是律师,但是...据我所知,没有法律要求将许可证包含在每个源文件,只是人们喜欢捂屁股。 将您的许可证包含在清晰的 README.txt 或 LICENSE.txt 中以及您发布源代码的位置应该就足够了。 如果这让您失眠,只需编写一个填充许可证注释的脚本即可。
根据评论进行更新:
如果您确实需要以明确的方式回答此问题,我建议您联系软件自由.org
Do you really care if someone "steals" your unit tests?
I am not a lawyer but ... AFAIK, There is no legal requirement to include the license in every source file, it's just that people like covering their butts. Including your license in a clear README.txt or LICENSE.txt and in the place where you publish your source should be good enough. If this is making you lose sleep just write a script that populates the license comment.
Update based on the comment:
If you really need to get this question answered in a definate manner I suggest you contact software freedom .org
对于了解脚本语言的人来说,向项目中的每个源文件添加版权标头是一个非常简短的项目。 如果您不了解 Perl、Python 或 Ruby 等脚本语言,现在是开始学习的好时机。
例如,下面是一个向自身添加版权标头的 Perl 脚本:
根据程序的结构,您可以用版权标头替换原始文件中的标签,或者仅将标头添加到文件的最顶部。
Adding copyright headers to every source file in your project is a very brief project for someone who knows a scripting language. If you don't know a scripting language like Perl, Python or Ruby, this is a good time to start learning one.
For example, here's a Perl script that adds a copyright header to itself:
Depending on the structure of your program, you can either replace a tag in the original file with a copyright header, or just add the header to the very top of the file.
懒惰和跳过步骤总是不好的。 做正确的事。 高效地做事。 永远这样做。 故事结局。
Laziness and skipping steps is always bad. Do the right thing. Do it efficiently. Do it always. End of story.