如何确保 java-maven 构建的所有源文件都附有版权声明?
人们是否有一种标准方法可以强制在其 java/maven 构建中包含版权声明?我意识到这不是必要的,因为产品本身是抄写的,如果有人有我的源代码,我就会遇到更大的问题,但我被要求检查,并且想知道 checkstyle、PMD 或其他东西是否自动处理这个问题。
有没有一个工具可以处理版权检查?
Is there a standard way people enforce the inclusion of copyright notices in their java/maven builds? I realize that it shouldn't be necessary since the product itself is copy-written and if someone has my source I have much bigger problems, but I'm being asked to check and was wondering if checkstyle, PMD or something else handled this automatically.
Is there a tool which handles checking for copyright?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是,Checkstyle(以及 maven-checkstyle-plugin< /a>) 可以做到这一点,它可以检查每个源文件是否包含许可证头。将该标头放入文本文件中并使用
headerLocation
指向它(默认使用LICENSE.txt
)。假设您想使用
checkstyle.license
作为版权声明。对于多模块构建,标准方法是创建一个专用模块来托管 Checkstyle 资源(请参阅 多模块配置):然后,包含 Checkstyle 配置位于顶级
pom.xml
中。此设置将确保源文件中存在版权标头(并应用其他 Checkstyle 规则,但这是另一个故事)。对其进行调整以满足您的需求。
Yes, Checkstyle (and the maven-checkstyle-plugin) can do that, it can check that every source files do contain a license header. Put that header in a text file and use the
headerLocation
to point on it (it uses by defaultLICENSE.txt
).Let's say you want to use
checkstyle.license
for your copyright notices. For a multi-modules build, the standard approach is to create a dedicated module to host Checkstyle resources (see Multimodule configuration):Then, include the Checkstyle configuration in the top level
pom.xml
.This setup will ensure that a copyright header is present in source files (and apply other Checkstyle rules but this is another story). Adapt it to suit your needs.
我刚刚发现
http://code.google.com/p/maven-license-plugin/< /a>
似乎也有道理
I just found
http://code.google.com/p/maven-license-plugin/
seems reasonable too
如果您的项目位于 Git 存储库中,您可以遵循欧洲自由软件基金会的 REUSE 标准。使用reuse-tool,您可以通过执行
reuse lint。对于持续集成 (CI),您可以使用 fsfe/reuse Docker 映像。
If your project is in a Git repository, you can follow the REUSE standard from the Free Software Foundation Europe. With the reuse-tool you can check REUSE compliance by executing
reuse lint
. For continuous integration (CI) you can use the fsfe/reuse Docker image.