question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add support for a file name field in license headers

See original GitHub issue

It 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:open
  • Created 2 years ago
  • Reactions:1
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
nedtwiggcommented, Mar 14, 2022

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.

0reactions
OxygenCobaltcommented, Mar 20, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found