Add support for a file name field in license headers
See original GitHub issueIt would be useful if there was a field in the license header template called $FILE
, $file.fileName
, or similar that would be replaced with the name of the file the header is being applied to.
For example, I could write something like:
/*
* Copyright (c) 2021 OxygenCobalt
* $file.fileName is part of Foo.
*/
And it would end up resolving to:
/*
* Copyright (c) 2021 OxygenCobalt
* Bar.kt is part of Foo.
*/
I’m mostly drawing this idea from IntelliJ’s Copyright Notice format.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Add the file name, date, author or other document properties ...
Go to Insert > Header or Footer. · Select Edit Header or Edit Footer. · Select Quick Parts, and select Field. · In...
Read more >How to add file name and date dynamically in *.licenseheader ...
Finally I found the way to define file name and created date time dynamically. We can use "%FileName%", "%CreationYear%" etc. For example :...
Read more >Adding a Copyright License Header for Java Source Files in ...
In this tutorial, we're going to look at how to add a license header to our IntelliJ IDEA project files. The license header...
Read more >Add license header - OpenRewrite
AddLicenseHeader Adds license headers to Java source files when missing. ... In your rewrite.yml create a new recipe with a unique name.
Read more >Content-Disposition - HTTP - MDN Web Docs
The first directive is always form-data , and the header must also include a name parameter to identify the relevant field. Additional ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
For substitutions that have constant values (e.g. Module and Project) you can do this already via
replaceRegex
.To inject something dynamic like the filename or author, you’ll have to create a custom step, and it’s pretty straightforward to modify the LicenseStep to do this.
Honestly, I’d be willing to add most of the copyright notice format to the license header functionality in a PR. I feel like that would definitely help people trying to migrate from the somewhat unreliable IntelliJ plugin to spotless without issue. The only issue is that I’m quite busy right now, so I won’t be able to get to it immediately.