-
Notifications
You must be signed in to change notification settings - Fork 461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for a file name field in license headers #1147
Comments
fileName
in license headers
Happy to take a PR for this. |
Well, I'm not too familiar with spotless's codebase, but I can try to take a crack at it. |
I stumbled upon this issue when I was attempting to setup Spotless for my Android project whose copyright header template is:
I did upvote this. AFAIK, the Spotless license header check is language/platform/IDE agnostic and most of these variables are injected by Android Studio. So not sure whether this is a legible feature request. |
Just wondering, as a stop-gap solution, whether we could put support for Regex in
|
For substitutions that have constant values (e.g. Module and Project) you can do this already via 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. |
Thanks, @nedtwigg for the help and for pointing me in the right direction. Will have a look into 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. |
Hey, |
Published in |
This MR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [flow-bin](https://github.com/flowtype/flow-bin) ([changelog](https://github.com/facebook/flow/blob/master/Changelog.md)) | devDependencies | minor | [`^0.206.0` -> `^0.214.0`](https://renovatebot.com/diffs/npm/flow-bin/0.206.0/0.214.0) | | [org.liquibase.ext:liquibase-hibernate5](https://github.com/liquibase/liquibase-hibernate/wiki) ([source](https://github.com/liquibase/liquibase-hibernate)) | build | minor | `4.21.1` -> `4.22.0` | | [org.liquibase:liquibase-maven-plugin](http://www.liquibase.org/liquibase-maven-plugin) ([source](https://github.com/liquibase/liquibase)) | build | minor | `4.21.1` -> `4.23.0` | | [com.vladsch.flexmark:flexmark-all](https://github.com/vsch/flexmark-java) | compile | patch | `0.64.4` -> `0.64.8` | | [com.diffplug.spotless:spotless-maven-plugin](https://github.com/diffplug/spotless) | build | minor | `2.36.0` -> `2.38.0` | --- ### Release Notes <details> <summary>flowtype/flow-bin</summary> ### [`v0.214.0`](flow/flow-bin@a8d35e6...ca11e28) [Compare Source](flow/flow-bin@a8d35e6...ca11e28) ### [`v0.213.1`](flow/flow-bin@656b64a...a8d35e6) [Compare Source](flow/flow-bin@656b64a...a8d35e6) ### [`v0.213.0`](flow/flow-bin@733e908...656b64a) [Compare Source](flow/flow-bin@733e908...656b64a) ### [`v0.212.0`](flow/flow-bin@d057186...733e908) [Compare Source](flow/flow-bin@d057186...733e908) ### [`v0.211.1`](flow/flow-bin@669f2d7...d057186) [Compare Source](flow/flow-bin@669f2d7...d057186) ### [`v0.211.0`](flow/flow-bin@c0f5f12...669f2d7) [Compare Source](flow/flow-bin@c0f5f12...669f2d7) ### [`v0.210.2`](flow/flow-bin@6dbf435...c0f5f12) [Compare Source](flow/flow-bin@6dbf435...c0f5f12) ### [`v0.210.1`](flow/flow-bin@572b4ff...6dbf435) [Compare Source](flow/flow-bin@572b4ff...6dbf435) ### [`v0.210.0`](flow/flow-bin@026a117...572b4ff) [Compare Source](flow/flow-bin@026a117...572b4ff) ### [`v0.209.0`](flow/flow-bin@b1689a0...026a117) [Compare Source](flow/flow-bin@b1689a0...026a117) ### [`v0.208.1`](flow/flow-bin@1e8564c...b1689a0) [Compare Source](flow/flow-bin@1e8564c...b1689a0) ### [`v0.208.0`](flow/flow-bin@97db57b...1e8564c) [Compare Source](flow/flow-bin@97db57b...1e8564c) ### [`v0.207.0`](flow/flow-bin@7bf1c0e...97db57b) [Compare Source](flow/flow-bin@7bf1c0e...97db57b) </details> <details> <summary>liquibase/liquibase-hibernate</summary> ### [`v4.22.0`](https://github.com/liquibase/liquibase-hibernate/releases/tag/v4.22.0) [Compare Source](liquibase/liquibase-hibernate@v4.21.1...v4.22.0) Support for Liquibase 4.22.0. #### What's Changed - Fix diff changelog is removing unique constraint since 4.21.0 (hibernate6 + postgresql) by [@​filipelautert](https://github.com/filipelautert) in liquibase/liquibase-hibernate#480 - add Support for Hibernate EnversSettings revision_field_name and revision_type_field_name by [@​lorenzbaier](https://github.com/lorenzbaier) in liquibase/liquibase-hibernate#488 - Bump spring.version from 6.0.8 to 6.0.9 by [@​dependabot](https://github.com/dependabot) in liquibase/liquibase-hibernate#490 #### New Contributors - [@​lorenzbaier](https://github.com/lorenzbaier) made their first contribution in liquibase/liquibase-hibernate#488 **Full Changelog**: liquibase/liquibase-hibernate@v4.21.0...v4.22.0 </details> <details> <summary>liquibase/liquibase</summary> ### [`v4.23.0`](https://github.com/liquibase/liquibase/blob/HEAD/changelog.txt#Liquibase-4230-is-a-major-release) [Compare Source](liquibase/liquibase@v4.22.0...v4.23.0) ### [`v4.22.0`](https://github.com/liquibase/liquibase/blob/HEAD/changelog.txt#Liquibase-v4220-is-a-major-release) [Compare Source](liquibase/liquibase@v4.21.1...v4.22.0) </details> <details> <summary>vsch/flexmark-java</summary> ### [`v0.64.6`](vsch/flexmark-java@0.64.4...0.64.6) [Compare Source](vsch/flexmark-java@0.64.4...0.64.6) </details> <details> <summary>diffplug/spotless</summary> ### [`v2.38.0`](https://github.com/diffplug/spotless/blob/HEAD/CHANGES.md#​2380---2023-04-06) ##### Added - Support configuration of mirrors for P2 repositories in `EquoBasedStepBuilder` ([#​1629](diffplug/spotless#1629)). - The `style` option in Palantir Java Format ([#​1654](diffplug/spotless#1654)). - Added formatter for Gherkin feature files ([#​1649](diffplug/spotless#1649)). ##### Changes - **POTENTIALLY BREAKING** Converted `googleJavaFormat` to a compile-only dependency and drop support for versions < `1.8`. ([#​1630](diffplug/spotless#1630)) - Bump default `cleanthat` version to latest `2.6` -> `2.13`. ([#​1589](diffplug/spotless#1589) and [#​1661](diffplug/spotless#1661)) - Bump default `diktat` version `1.2.4.2` -> `1.2.5`. ([#​1631](diffplug/spotless#1631)) - Bump default `flexmark` version `0.62.2` -> `0.64.0`. ([#​1302](diffplug/spotless#1302)) - Bump default `googleJavaFormat` version `1.15.0` -> `1.16.0`. ([#​1630](diffplug/spotless#1630)) - Bump default `scalafmt` version `3.7.1` -> `3.7.3`. ([#​1584](diffplug/spotless#1584)) - Bump default Eclipse formatters for the 2023-03 release. ([#​1662](diffplug/spotless#1662)) - JDT and GrEclipse `4.26` -> `4.27` - Improve GrEclipse error reporting. ([#​1660](diffplug/spotless#1660)) - CDT `11.0` -> `11.1` ### [`v2.37.0`](https://github.com/diffplug/spotless/blob/HEAD/CHANGES.md#​2370---2023-03-13) ##### Added - You can now put the filename into a license header template with `$FILE`. ([#​1605](diffplug/spotless#1605) fixes [#​1147](diffplug/spotless#1147)) ##### Changes - We are now opting in to Gradle's new stable configuration cache. ([#​1591](diffplug/spotless#1591)) - Adopt [Equo Solstice OSGi and p2 shim](https://github.com/equodev/equo-ide/tree/main/solstice) to update all Eclipse-based plugins. ([#​1524](diffplug/spotless#1524)) - Eclipse JDT now supports `4.9` through `4.26`. Also we now recommend dropping the last `.0`, e.g. `4.26` instead of `4.26.0`, you'll get warnings to help you switch. - Eclipse Groovy now supports `4.18` through `4.26`. Also we now recommend dropping the last `.0`, e.g. `4.26` instead of `4.26.0`, you'll get warnings to help you switch. - Eclipse CDT now supports `10.6` through `11.0`. - Eclipse WTP is still WIP at [#​1622](diffplug/spotless#1622). </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever MR is behind base branch, or you tick the rebase/retry checkbox. 👻 **Immortal**: This MR will be recreated if closed unmerged. Get [config help](https://github.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC4yNC4wIiwidXBkYXRlZEluVmVyIjoiMzQuMjQuMCJ9-->
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:
And it would end up resolving to:
I'm mostly drawing this idea from IntelliJ's Copyright Notice format.
The text was updated successfully, but these errors were encountered: