We have the requirement to add license headers to all of our source files.
One speciality is that we need to be able to have placeholders for multiple years as part of the copyright notes.
In a Maven build, I would use com.mycila:license-maven-plugin to do the job, which is in fact working in another repository for us.
Do you know of any other Gradle plugins which could accomplish the requirements of working, maintained, and supporting multiple/repeating placeholders?
Fwiw, I use the checkstyle plugin for this from standard Gradle.
For me, the Header check has always been enough, but there is even RegexpHeader, which allows using regular expressions on the header. They even have some examples with copyright years. Both checks work for all text files, not just Java.
Checkstyle can check many more things about your code, but there’s nothing stopping you from configuring only one check.
Edit: If you need to check license headers in all files of the project (or at least more than just the source code), then you can configure Checkstyle in Gradle to do that.
As far as I can see, Checkstyle cannot be used to add, update, or remove license headers from files, correct?
This would be necessary to reduce the manual work required for our legal requirement having up-to-date license headers/preambles in our source and configuration files.
As far as I can see, Checkstyle cannot be used to add, update, or remove license headers from files, correct?
True. I didn’t see that requirement in your question.
We use our IDE for that. IntelliJ, for example, has a file templates feature that even features placeholder variables for things like a year number.
But once a year, someone needs to run a script that updates the year numbers in all the headers. Thanks to the Checkstyle checking, the script always works.