[question] Is there a way to skip licenseHeader for legacy files while keeping other formatters active?
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- java
- Domain
- build-system, tooling
Research direction
Start with the Maven Spotless configuration and the licenseHeader delimiter shown in the issue, then review how the listed formatting steps are applied to Java files. Determine whether licenseHeader can be limited to new files without excluding the other steps; done means new files receive the header, legacy headers remain unchanged, and all other formatters still run.
Written by the indexing model from the issue text.
Description
Environment:
- Java
- Spotless Maven Plugin
Background
Our project contains both new and legacy Java files:
- New files contain only the new license header:
// New License Header - Legacy files contain multiple historical license headers, for example:
// New License Header // Old License Header
Problem
When configuring Spotless with:
<licenseHeader>
<file>${project.basedir}/tools/spotless/license-header.txt</file>
<delimiter>package |import |module </delimiter>
</licenseHeader>
Spotless replaces all license headers in all files, including legacy files that should keep their original headers.
This causes two issues:
- Legacy files lose their historical license information
- If I exclude legacy files from
licenseHeader, then other formatters (googleJavaFormat,eclipse,prettier,idea,tableTestFormatter,importOrder) will also stop applying to them
Expected Behavior
- New files should receive the new license header
- Legacy files should keep their existing headers, but still be formatted by other Spotless steps
Question
Is there a recommended way to configure Spotless so that:
licenseHeaderapplies only to new files- Other formatters still apply to all files
- Legacy files are not modified by the license step
- Dominant language
- Java
- Stars
- 5.7k
- Forks
- 560
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 43
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from diffplug/spotless
-
Difficulty 5/5 Over a week Newbie friendliness 15/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 66/100
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
All issues in diffplug/spotless
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
opensearch-project/k-NN#3597 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100