如何将当前年份插入 IntelliJ IDEA 版权模板?
How do you insert the current year into IntelliJ IDEA Copyright template?
我正在尝试在 IntelliJ IDEA 版权设置中为 MIT 许可证制作 Apache Velocity 模板。我希望它在年份所在的位置打印 2015-${current_year}
。这是我尝试在 设置 → 版权 → 版权配置文件 → MIT → 版权文本 :
中输入的内容
#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.
但是,当我使用此模板在我的源文件中生成许可证 header 时,它不会打印当前年份编号,它只会打印纯文本 ${current_year}
.
如何让它打印当前年份?
This page of the documentation 解释了 设置的内置 Velocity 变量 → 版权 → 版权配置文件:
Name Type Comment
$today DateInfo The current date and time.
...
DateInfo has the following properties:
year int The current year.
所以就我而言,我的模板中需要这个:
Copyright (c) 2015-${today.year}, My Name
#set($year = $today.year + 1900)
又可以称为${year}
如所述here,${YEAR}
是要走的路
我正在尝试在 IntelliJ IDEA 版权设置中为 MIT 许可证制作 Apache Velocity 模板。我希望它在年份所在的位置打印 2015-${current_year}
。这是我尝试在 设置 → 版权 → 版权配置文件 → MIT → 版权文本 :
#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.
但是,当我使用此模板在我的源文件中生成许可证 header 时,它不会打印当前年份编号,它只会打印纯文本 ${current_year}
.
如何让它打印当前年份?
This page of the documentation 解释了 设置的内置 Velocity 变量 → 版权 → 版权配置文件:
Name Type Comment
$today DateInfo The current date and time.
...
DateInfo has the following properties:
year int The current year.
所以就我而言,我的模板中需要这个:
Copyright (c) 2015-${today.year}, My Name
#set($year = $today.year + 1900)
又可以称为${year}
如所述here,${YEAR}
是要走的路