[英]How can i ensure all my java projects in a git repository have latest or desired version of maven dependency?
[英]How do I ensure that copyright notices accompany all of my source files for a java-maven build?
人们是否有一种标准的方式来强制在他们的 java/maven 构建中包含版权声明? 我意识到它不应该是必要的,因为产品本身是复制编写的,如果有人有我的来源,我会遇到更大的问题,但我被要求检查并想知道 checkstyle、PMD 或其他东西是否自动处理了这个问题.
是否有处理版权检查的工具?
是的,Checkstyle(和maven-checkstyle-plugin )可以做到这一点,它可以检查每个源文件是否包含许可证头。 将该标题放在一个文本文件中,并使用headerLocation
指向它(它默认使用LICENSE.txt
)。
假设您想将checkstyle.license
用于版权声明。 对于多模块构建,标准方法是创建一个专用模块来托管 Checkstyle 资源(请参阅多模块配置):
whizbang
|-- pom.xml
|-- build-tools
| |-- src
| | `-- main
| | `-- resources
| | `-- whizbang
| | |-- checkstyle.xml
| | `-- checkstyle.license
| `-- pom.xml
|-- core
|-- gui
|-- jmx
`-- src
然后,在顶层pom.xml
包含 Checkstyle 配置。
<pluginManagement>
<plugins>
<!-- Apply checkstyle rules and fail the build in case of errors. The
checkstyle config files are taken from the build-tools JAR module.-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<!-- Lock down plugin version for build reproducibility -->
<version>2.4</version>
<dependencies>
<dependency>
<groupId>com.example.whizbang</groupId>
<artifactId>build-tools</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
<configuration>
<consoleOutput>true</consoleOutput>
<configLocation>whizbang/checkstyle.xml</configLocation>
<headerLocation>whizbang/checkstyle.license</headerLocation>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
...
</plugins>
</pluginManagement>
此设置将确保源文件中存在版权标头(并应用其他 Checkstyle 规则,但这是另一回事)。 调整它以满足您的需求。
如果您的项目位于 Git 存储库中,您可以遵循欧洲自由软件基金会的REUSE 标准。 使用重用工具,您可以通过执行reuse lint
来检查reuse lint
合规性。 对于持续集成 (CI),您可以使用fsfe/reuse Docker 映像。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.