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?
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.