I have a copyright profile defined in IntelliJ as Copyright ${today.year}, All Rights Reserved.
This works great on new files, however on existing files I would like to update the existing year to a range or update the end-date of an existing range to ${today.year}
.
IntelliJ supports using Velocity in copyright templates. Is there a way to leverage Velocity to do this? From what I can tell, Velocity allows for if-statements yet I am unsure how to get the previous years as variables.
Examples:
New document: Copyright 2018
Copyright 2017
to Copyright 2017-2018
Copyright 2015-2017
to Copyright 2015-2018
Reference:
IntelliJ supported variables
Velocity User Guide
I am unsure how to get the previous years as variables
As far as I can see, exactly this will be the breaker. If you could access the creation date of the file, it would be simple to compare "today" with the year of creation and make a copyright you want.
On the other hand, those copyrights are usually project-based, although they appear in each file. I never saw that files have different entries for the date in the copyright.
Therefore, if you want a simple solution, just use
Copyright 2017-${today.year}
If you happen to start a project 2018, just use 2018 and when the year changes, make the above adaption to your copyright and update all files. You need to do this only once with new projects and spending even 15 min fiddling around with the Velocity templates is more time than you need to make the adaption in the copyright.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With