Description
I'm trying use Spotless 2.7.0 to onboard a repository and inject license headers, via the maven plugin. Existing sources are in a variety of states, many without any header, some with a outdated header that hasn't been maintained, some with a history pre-dating the git history.
For example, with the following files, running mvn spotless:apply
I get the "Default Result", whereas running mvn spotless:apply -DspotlessSetLicenseHeaderYearsFromGitHistory=true
I get the "FromGit Result", but I'd really like to get the "Desired Result".
File | Current Year | Header Range | Git Range | Default Result | FromGit Result | Desired Result |
---|---|---|---|---|---|---|
new.java |
2021 | None | 2021 | 2021 | 2021 | ✅ 2021 |
old.java |
2021 | None | 2019-2020 | 2021 | 2019-2020 | ⛔ 2019-2021 |
outdated.java |
2021 | 2019 | 2018-2020 | 2019-2021 | 2018-2020 | ⛔2018-2021 |
prehistory.java |
2021 | 2016-2020 | 2019-2020 | 2016-2021 | 2019-2020 | ⛔2016-2021 |
For old.java
, outdated.java
, prehistory.java
with the -DspotlessSetLicenseHeaderYearsFromGitHistory=true
option I think the Git Range should be extended to include the Current Year, as the change will be committed in the current year. This effect can be achieved manually by rerunning without the -DspotlessSetLicenseHeaderYearsFromGitHistory=true
option but I don't think that should be necessary.
For prehistory.java
with the -DspotlessSetLicenseHeaderYearsFromGitHistory=true
option I think the date range should also be extended to incorporate the date range claimed in the existing license Header Range. To ignore the existing license header range results in data loss and a narrower copyright claim which is a problem.
Would it be reasonable to extend spotlessSetLicenseHeaderYearsFromGitHistory
functionality to incorporate these new behaviours?
Would it be necessary to add further options so that current behaviour can be maintained too?