Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you insert the current year into IntelliJ IDEA Copyright template?

I'm trying to make an Apache Velocity template for MIT license in IntelliJ IDEA copyright settings. I want it to print 2015-${current_year} where the year is. Here is what I've tried to put in Settings → Copyright → Copyright Profiles → MIT → Copyright text:

#set ($current_year = $dateTool.getCurrentDate('yyyy'))
Copyright (c)  2015-${current_year}, My Name

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

However, it doesn't print the current year number when I generate the license header in my source files using this template, it just prints plain text ${current_year}.

How do I make it print the current year?

like image 936
gvlasov Avatar asked Jun 03 '15 10:06

gvlasov


1 Answers

This page of the documentation explains the built-in Velocity variables for Settings → Copyright → Copyright Profiles:

Name    Type        Comment
$today  DateInfo    The current date and time.
...
DateInfo has the following properties:
year    int         The current year.

So in my case, I needed this in my template:

Copyright (c)  2015-${today.year}, My Name
like image 109
gvlasov Avatar answered Sep 20 '22 17:09

gvlasov