Updating Copyright Mentions with Eclipse
There is one thing I try to take care of every year: update the copyright mentions in the source code of my open source projects.
I could do this just when I modify a source file.
But I never think about checking it, and this is painful. The best solution is to update these mentions at the beginning of every year, in all the files, in a single row. And to perform this bulk task, I use my favorite IDE: Eclipse.
There are 2 kinds of mentions to update.
But the path is the same. It starts by checking out all the projects in the workspace, followed by Search > File…
Last Year Mentions
The first kind of mention is quite simple, as an example:
Copyright (c) 2012, Linagora
It means the file was created in 2012.
The search options are quite trivial here. Disable the Regular expression checkbox. Search any file (*, the star symbol). Type in the search text and click Replace… Once the search has been performed, type in the replacement text in the shown dialog.
Copyright (c) 2012-2013, Linagora
The second kind of mention covers several years, e.g.
Copyright (c) 2009-2012, Linagora
We are going to replace all the occurrences once again. But the search box will rely on more advanced options. Make sure Regular expression is checked and search for…
Copyright \(c\) 20(\d\d)-2012, Linagora
Remember to click Replace… and not Search…
Then, add the following replacement text.
Copyright (c) 20$1-2013, Linagora
And voilà! All your copyright mentions have been updated. And you can save them in a single commit.
Coupled to build rules (e.g. with Sonar) and the right template files for your source code, you will not have to think about copyright mentions before next year.